I'm playing about with some types and the PureScript compiler. These are the types I've created (liberally stolen from purescript-dsl-example):
newtype User = User
{ id :: Int
, name :: String
}
data Command a = Add User a
| Remove Int a
| ChangeName Int String a
This type checks and compiles. Then, thinking it might be useful to be able to serialise these types into JSON, I installed purescript-foreign-generic
and added this:
derive instance genericCommand :: Generic Command _
As a first step towards a Show instance.
The type checker then throws this error:
Error found:
in module Main
at src/Main.purs:33:43 - 33:50 (line 33, column 43 - line 33, column 50)
Could not match kind
Type
with kind
Type -> Type
while checking the kind of Generic Command (Sum (Constructor "Add" (Product ... ...)) (Sum (Constructor "Remove" ...) (Constructor "ChangeName" ...)))
in value declaration genericCommand
Is there a way to derive a Generic instance from my type? If not, is there a way I can write a Generic instance manually? I have no idea what that would entail, so am okay with admitting I'm not sure if that last question even makes sense.