Jay Cox complained that the following is not possible:
| data S m a = Nil | Cons a (m (S m a))
|
| instance (Show a, Show (m (S m a))) => Show (S m a) where
| show Nil = "Nil"
| show (Cons x y) = "Cons " ++ show x ++ " " ++ show y
Ken Shan answered:
| Here's how I've been handling such situations:
|
| data S m a = Nil | Cons a (m (S m a))
|
| -- "ShowF f" means that the functor f "preserves Show"
| class ShowF f where
| showsPrecF :: (Int -> a -> ShowS) -> (Int -> f a -> ShowS)
Actually, this class definition can be simplified to:
class ShowF f where
showsPrecF :: Show a => Int -> f a -> ShowS
And the rest of Ken's code accordingly.
/Koen.
--
Koen Claessen http://www.cs.chalmers.se/~koen
phone:+46-31-772 5424 mailto:[EMAIL PROTECTED]
-----------------------------------------------------
Chalmers University of Technology, Gothenburg, Sweden
_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe