X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fharbl.git;a=blobdiff_plain;f=src%2FPretty.hs;h=91158065ff717ddc71bc2b909c25ee422de49e7d;hp=360bd4c1b8a4ded3875972f8a30c195284051c5e;hb=476eee96bdc3a85449769a556852f2737614572f;hpb=edb0055e306eb6b323bbc75bfb7d15089344af81 diff --git a/src/Pretty.hs b/src/Pretty.hs index 360bd4c..9115806 100644 --- a/src/Pretty.hs +++ b/src/Pretty.hs @@ -7,7 +7,7 @@ -- way. The 'pretty_print' function then prints the result of -- 'pretty_show' by default. -- -module Pretty +module Pretty ( Pretty(..) ) where import Text.Parsec ( ParseError ) @@ -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