I'm attempting to serialize data types in Haskell, and would like to know how to serialize a GADT. The method I have attempted looks something like (using Control.DeepSeq):
data Gadt a where
Cons1 :: Int -> Gadt Int
Cons2 :: Bool -> Gadt Bool
instance NFData Cons1 where rnf = genericRnf
instance NFData Cons2 where rnf = genericRnf
deriveSafeCopy ......
However, this does not compile: GHC tells me that Cons1 and Cons2 are not valid constructors. I can serialize standard data types just fine. What is the optimal way to serialize GADTs?
The reason I want to serialize GADTs is since this data type is a key in a Redis Database that I'm using for my project.
Cons1 :: forall a . a -> Gadt Int
so I think you are really trying to do something else? – Random Dev