{-# LANGUAGE TypeSynonymInstances #-} module Foo where import Text.XHtml.Strict data MyData = Foo {nums :: [Int]} | Bar {strs :: [String]} instance HTML Int where toHtml = primHtml.show instance HTML String where toHtml = primHtml instance HTML MyData where toHtml (Foo ns) = primHtml ("Integers "++(show ns)) toHtml (Bar ss) = primHtml ("Strings "++(show ss)) gen listFunc (Foo ns) | length ns == 0 = p << "no integers" | length ns == 1 = p << "one integer" +++ (p << (listFunc ns)) | length ns == 2 = (h1 << "several integers") +++ (p << (listFunc ns)) gen listFunc (Bar ss) = (h1 << "Bar Heading") +++ (p << (listFunc ss)) foo = gen unordList {- Without a type signature for gen, it gives this error: Foo.hs:26:35: Couldn't match expected type `[Char]' against inferred type `Int' Expected type: [String] -> a Inferred type: [Int] -> a1 In the second argument of `(<<)', namely `(listFunc ss)' In the second argument of `(+++)', namely `(p << (listFunc ss))' -}