我尝试将JSON对象流式传输到客户端,以便获得更新通知。
我的接口声明如下:
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)我使用的是Servant 0.19.2。(SerialT来自streamly)
发布于 2020-07-23 23:00:03
因为我使用了一个自定义的流支持库,所以它(实例定义模块)应该在服务器定义过程中被导入。
https://stackoverflow.com/questions/62982656
复制相似问题