Tomasz Zielonka wrote:
BTW, This thread reminds me a similar problem that was discussed on haskell list. Unfortunately, there were some problems with this approach (accumulating typeclass contexts).
http://www.haskell.org/pipermail/haskell/2004-August/thread.html#14427
Yes, quite relevant.
In "Scrap your boilerplate", we had the strong version of this problem.
Say, one would want to provide type-specific instances for some generic function, which however seemed impossible in the view of the Data methods whose types only mention the Data (and Typeable) class. (So while run-time type case via cast, mkT, etc. would be easy, it was unclear how to do static and modular type-case.)
The problem is solved now!
The Data class subclasses a dedicated customisation class, we call this class Property
for now. This is a two-parameter class; one param for the property (which is
a type constructor of kind * -> *), and another for the type at hand. The property
class context is propagated during descent into substructures by suitably constraining
the type of the method gfoldl.
The general pattern of class context parameterisation is of course not restricted to SYB.
The SYB site (FAQ, last item) provides details including a longer code snippet.
Paper forthcoming.
Ralf
_______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell