safecopy
safecopy copied to clipboard
SafeCopy instance of a parameterized type
There are circumstances where more context is needed on the type parameter when generating a SafeCopy instance from T1 typ. For example, http://lpaste.net/135048 is a module where the IxSet types create a need for Data, Typeable, and Ord. I'm not yet sure what the correct solution is to this issue, but for the moment I've added these superclasses to our version of safecopy.
The error messages I get from that module look like this:
Bug.hs:41:49:
Could not deduce (Typeable typ) arising from a use of ‘getSafePut’
from the context (SafeCopy typ)
bound by the instance declaration
at Bug.hs:(32,10)-(39,31)
In a stmt of a 'do' block: safePut_IxSetT1typtyp <- getSafePut
In the second argument of ‘($)’, namely
‘do { safePut_IxSetT1typtyp <- getSafePut;
safePut_IxSetT1typtyp arg;
return () }’
In the expression:
contain
$ do { safePut_IxSetT1typtyp <- getSafePut;
safePut_IxSetT1typtyp arg;
return () }
I just noticed that the context of the data declaration is added to the SafeCopy declaration, so you can fix this by adding context to T2. However, the DatatypeContexts feature is considered a bad thing.
I'm closing this because I'm no longer certain the DatatypeContexts directive is necessary.
Ok, I've updated the example http://lpaste.net/135048 to show that it does require DatatypeContexts to build. Reopening.
This is now fixed.
No, its not.
http://lpaste.net/146499 is a file that demonstrates the issue.