Skip to content
David Fox edited this page Dec 8, 2016 · 2 revisions

Welcome to the safecopy wiki!

Chapter 1. Advice for those who want to create SafeCopy instances for parameterized types

If you have a parameterized type such as

data UserProfile capability
  = UserProfile { _groups :: Set (GroupID, capability) ... }

when you try to

$(deriveSafeCopy 1 'base ''UserProfile)

you will find that ghc complains that there is no Ord instance for capability. This is because the generated code tries to get and put values of type Set (GroupID, capability), but in the expression it builds it requires the Ord capability instance implied by Set, which is not available at that particular point. In my case I solved this by changing Set(GroupID, capability) to Map GroupID capability, because Map doesn't need the values to be Ord. A satisfying solution in this case, hopefully your solution will be as simple.