首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >servant无法流式传输JSON

servant无法流式传输JSON
EN

Stack Overflow用户
提问于 2020-07-20 00:06:29
回答 1查看 105关注 0票数 2

我尝试将JSON对象流式传输到客户端,以便获得更新通知。

我的接口声明如下:

代码语言:javascript
复制
type API = "poll" :> StreamGet NewlineFraming JSON (SerialT IO Notification)

我得到了以下错误:

代码语言:javascript
复制
• Could not deduce (ToJSON chunk0) arising from a use of ‘serve’
      from the context: P.Persist p
        bound by the type signature for:
                   app :: forall (p :: * -> *).
                          P.Persist p =>
                          PollRoute p -> P.Configuration p -> Application
        at app/Main.hs:93:1-70
      The type variable ‘chunk0’ is ambiguous
      These potential instances exist:
        instance ToJSON DotNetTime
          -- Defined in ‘aeson-1.4.7.1:Data.Aeson.Types.ToJSON’
        instance ToJSON Value
          -- Defined in ‘aeson-1.4.7.1:Data.Aeson.Types.ToJSON’
        instance (ToJSON a, ToJSON b) => ToJSON (Either a b)
          -- Defined in ‘aeson-1.4.7.1:Data.Aeson.Types.ToJSON’
        ...plus 46 others
        ...plus 70 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)

我使用的是Servant 0.19.2。(SerialT来自streamly)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-23 23:00:03

因为我使用了一个自定义的流支持库,所以它(实例定义模块)应该在服务器定义过程中被导入。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62982656

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档