{-# LANGUAGE TypeSynonymInstances #-} module Foo where import Text.XHtml.Strict data MyData = Foo {nums :: [Int]} | Bar {strs :: [Double]} instance HTML Int where toHtml = primHtml.show instance HTML Double where toHtml = primHtml.show instance HTML MyData where toHtml (Foo ns) = primHtml ("Integers "++(show ns)) toHtml (Bar ss) = primHtml ("Doubles "++(show ss)) gen (Foo ns) | length ns == 0 = p << "no integers" | length ns == 1 = p << "one integer" +++ (p << (unordList ns)) | length ns == 2 = (h1 << "several integers") +++ (p << (unordList ns)) gen (Bar ss) = (h1 << "Bar Heading") +++ (p << (unordList ss)) {- This one compiles fine. -}