Suppose we have the following:

 data Foo x
 list_foo :: [x] -> Foo x
 foo_list :: Foo x -> [x]

What would be the best way to write a Show instance?

The thing that I came up with is

 instance (Show x) => Show (Foo x) where
   show foo = "list_foo " ++ show (foo_list foo)

But apparently you're supposed to use the strange "showsPrec" method that I don't understand. So can somebody show me a correct instance definition for this type please?

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to