Haskell 服务无法流式传输JSON
我尝试将JSON对象流式传输到客户端,以获得更新通知 我的API声明如下:Haskell 服务无法流式传输JSON,haskell,streaming,servant,Haskell,Streaming,Servant,我尝试将JSON对象流式传输到客户端,以获得更新通知 我的API声明如下: type API = "poll" :> StreamGet NewlineFraming JSON (SerialT IO Notification) 我得到了以下错误: • Could not deduce (ToJSON chunk0) arising from a use of ‘serve’ from the context: P.Persist p bo
type API = "poll" :> StreamGet NewlineFraming JSON (SerialT IO Notification)
我得到了以下错误:
• 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)
我使用的是仆人0.19.2。(
SerialT
来自streamly)因为我使用了自定义流媒体支持库,所以它(实例定义模块)应该在服务器定义期间导入。您的类型签名表示希望客户端接收类型为SerialT IO Notification
的值。我怀疑您是否真的想通过HTTP向客户端发送IO函数,请重新考虑该类型。在我完成Servant streamly支持时,我实际上已经测试过这种情况:。您是否有给出该类型错误的最小示例?API看起来不错(我为它编写流媒体服务器没有问题),所以错误一定在程序的其他地方。