仆人无法直播 JSON
servant cannot stream JSON
我尝试将 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
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)
由于我使用了自定义流媒体支持库,因此应该在服务器定义期间导入它(实例定义模块)。
我尝试将 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
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)
由于我使用了自定义流媒体支持库,因此应该在服务器定义期间导入它(实例定义模块)。