Re: [Haskell-cafe] Tree with collections

2006-03-13 Thread Henning Thielemann
On Sat, 11 Mar 2006, Roberto Zunino wrote: This avoids duplicating code between Show/ShowColl . instance ShowColl coll = Show (CollTree coll) where show (CollNode n) = CollNode ++ showColl n class ShowColl coll where showColl :: coll (CollTree coll) - String instance ShowColl []

[Haskell-cafe] Tree with collections

2006-03-11 Thread Henning Thielemann
I have a problem with defining an instance. module CollTree where import Data.List(intersperse) Say, I want to define a tree structure based on lists. I omit the data attached to the nodes here for simplicity. data ListTree = ListNode [ListTree] deriving Show This is simple

Re: [Haskell-cafe] Tree with collections

2006-03-11 Thread Roberto Zunino
Henning Thielemann wrote: Now I have to write 'show' related code for each collection type. This way I probably duplicate a lot of code that is already written for the Show instances of the collections. To be honest, I use a more special tree structure with even more special collections so