Bob, If you want to display them differently depending on how they were generated, I would wrap each one in a newtype. Then you can make the newtypes instances of different typeclasses. The wrapper remembers how the structure was generated, and using typeclasses, you should be able to treat each in the appropriate way pretty easily.
-Chad
Hi, I've met an interesting problem in terms of how to type a data structure and the functions that operate upon it. The problem centres around a single data type. This data type can be constructed in multiple ways using different functions, depending on the options the user specifies. That's all simple enough. The problem really comes later on. Depending on the function used generate the data structure I want to use different functions later on for example, to display the data. Thus I have a typical classes problem, in that I have several implementations of essentially the same function for different circumstances. The problem is, they must all operate on the same data type, so I cannot define them as seperate instances. Anyone got any ideas how to type this? Bob ------------------------------ _______________________________________________ Haskell mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell End of Haskell Digest, Vol 38, Issue 6 **************************************
-- Chad Scherrer "Time flies like an arrow; fruit flies like a banana" -- Groucho Marx _______________________________________________ Haskell mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell
