safecopy icon indicating copy to clipboard operation
safecopy copied to clipboard

SafeCopy instance of a parameterized type

Open ddssff opened this issue 9 years ago • 7 comments

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.

ddssff avatar Jun 23 '15 14:06 ddssff

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 () }

ddssff avatar Jun 23 '15 14:06 ddssff

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.

ddssff avatar Jun 23 '15 14:06 ddssff

I'm closing this because I'm no longer certain the DatatypeContexts directive is necessary.

ddssff avatar Jun 24 '15 17:06 ddssff

Ok, I've updated the example http://lpaste.net/135048 to show that it does require DatatypeContexts to build. Reopening.

ddssff avatar Jun 24 '15 17:06 ddssff

This is now fixed.

ddssff avatar Dec 04 '15 21:12 ddssff

No, its not.

ddssff avatar Dec 04 '15 22:12 ddssff

http://lpaste.net/146499 is a file that demonstrates the issue.

ddssff avatar Dec 05 '15 01:12 ddssff