
25 Apr
2008
25 Apr
'08
5:03 p.m.
Jonathan Cast wrote:
Type case is easy:
genericShow :: Typeable a => a -> String genericShow x = fromJust $ do s <- cast x :: Maybe String return s `mplus` do n <- cast x :: Maybe Int return (show n) `mplus` do return "<unknown>"
This is a nice idiom I didn't know before. Definitely worth page on the wiki or two. Cheers Ben