X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fharbl.git;a=blobdiff_plain;f=src%2FPretty.hs;h=14911246c8cd801a7f38b16aaef7a672e4c30bba;hp=84f9406bcd6187046442c9acddd1723f598f87d3;hb=80b389fd4d76bc8b2cb5dfad0f066fd7a838bdfb;hpb=b374bc7cc9ab43efbe659f681938ae2c54d01fc8 diff --git a/src/Pretty.hs b/src/Pretty.hs index 84f9406..1491124 100644 --- a/src/Pretty.hs +++ b/src/Pretty.hs @@ -22,6 +22,21 @@ class Pretty a where pretty_print = putStrLn . pretty_show +-- | If we can pretty print something, we can pretty-print a list of +-- them too. +-- +instance (Pretty a) => Pretty [a] where + pretty_show l = show $ map pretty_show l + + +-- | If we can pretty print something, we can pretty-print a pair of +-- them too. +-- +instance (Pretty a, Pretty b) => Pretty (a,b) where + pretty_show (x,y) = show (pretty_show x, pretty_show y) + + + -- | Define a 'Pretty' instance for the result of 'parse'. This lets -- us pretty-print the result of a parse attempt without worrying -- about whether or not it failed. If the parse failed, you get the