I have the following template & types:
data Obligation f a = ... -- a recursive ADT. Has some Bools and Decimals and manual Eq/Show instances. -- Identity monad newtype Id a = Id a deriving (Eq, Show) -- Specialized effect-less obligation for DvP type Obligations = Obligation Id (Either Ccy Security) -- Asset types data Ccy = GBP | USD deriving (Eq, Show) data Security = Security with isin: Text claims: Obligations deriving (Eq, Show) -- The financial contracts template DeliveryVersusPayment with bearer: Party counterparty: Party obligations: Obligations where signatory bearer, counterparty
And the compiler is complaining that the template is not serializable:
error type checking template DvPExamples.DeliveryVersusPayment :
expected serializable type:
- reason: template argument
- found: DvPExamples:DeliveryVersusPayment
unserializable data type DvPExamples:DeliveryVersusPayment
Which leads me to the question, how is serializability derived, and why does the compiler fail here? Could it be the recursion in the ADT?
Is it something I can prove to the compiler explicitly through a type
Is there some trick that can help me determine which type is not serializable here?