[Haskell-cafe] Show me
andrewcoppin at btinternet.com
Tue Aug 5 15:28:41 EDT 2008
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?
More information about the Haskell-Cafe