I try to stream JSON objects to clients in order to have update notifications.
My API is declared as following:
type API = "poll" :> StreamGet NewlineFraming JSON (SerialT IO Notification)
And I have got the following error:
• 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)
I am using Servant 0.19.2. (SerialT
comes from streamly)
Since I have used a custom streaming support library it should (the instance definition module) be imported during the server definition.