It seems like a reasonable and not-too-painful solution, thanks! Concerning Haskell typesystem, I know it to be beautiful, but also kind of complex. One of the great Haskell assets is genericity, but this complexity sometimes encumbers this genericity. But still, Haskell is -- in terms of flexibility -- way before other languages which pretend to be generic.
2010/4/18 Sebastian Fischer <s...@informatik.uni-kiel.de> > > On Apr 18, 2010, at 11:01 AM, Limestraël wrote: > > It's strange I can't declare a generic instance for Binary types... I >> thought I was trying to do something quite common in Haskell. >> > > A common workaround is to define a newtype like this > > newtype GenericBinary a = GB { fromGB :: a } > > and an instance like this > > instance Binary a => Binarizable (GenericBinary a) a where > toBinary = fromGB > > which only needs FlexibleInstances enabled. > > You can then 'tag' Binary types for which you want to use the generic > default instance above with the GB newtype constructor. Whether this is less > of a pain than implementing a Binarizable instance for each Binary type is a > different question.. > > Sebastian > > -- > Underestimating the novelty of the future is a time-honored tradition. > (D.G.) > > > >
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe