16
votes

I'm writing an open source patch to use a font library, or rather the haskell bindings to a font library in C (FTGL). I'm pointing to the Font type in one of the data structures, which is defined as follows:

type Font = Ptr Font_Opaque
data Font_Opaque

Unfortunately, to fit into the data structure of the library I'm patching, this type needs to be an instance of Data. Ptr already is, but Font_Opaque obviously isn't, so the compiler complains.

As it's an opaque type I'm not sure how to proceed ... how to implement Data Font_Opaque in a more or less sensible way? Is there a sensible way?

1
You could try deriving instance Data Font_Opaque (enable the StandaloneDeriving extension first) and then (if GHC can derive) look at the instance with -ddump-deriv.András Kovács

1 Answers

5
votes

As the comment by András Kovács suggests, using the StandaloneDeriving language extension

{-# LANGUAGE StandaloneDeriving -#}

and then:

deriving instance Data Font_Opaque

did the trick, at least where the compiler is concerned. I'll report back if this affects the program in any way. Thanks!