Open
Description
I have these data structures:
import Data.Generic.Rep (class Generic)
opts :: Options
opts = defaultOptions { unwrapSingleConstructors = true }
data Sum
= Nullary
| Unary Int
| UnaryNewType WrappedInt
newtype WrappedInt
= WrappedInt Int
derive instance sumGeneric :: Generic Sum _
derive instance wrappedGeneric :: Generic WrappedInt _
If I do
genericEncodeJSON opts (WrappedInt 8)
I corretcly get a 8
but If I do
genericEncodeJSON opts (UnaryNewType (WrappedInt 8))
I get an error about not being able to find the generic instance that was used in the first example:
No type class instance was found for
Foreign.Generic.Class.Encode WrappedInt
while applying a function genericEncodeJSON
of type Generic t0 t1 => GenericEncode t1 => { fieldTransform :: String -> String
, sumEncoding :: SumEncoding
, unwrapSingleArguments :: Boolean
, unwrapSingleConstructors :: Boolean
}
-> t0 -> String
to argument opts
while inferring the type of genericEncodeJSON opts
in value declaration main
What am I doing wrong here?
Metadata
Metadata
Assignees
Labels
No labels