From 476eee96bdc3a85449769a556852f2737614572f Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 8 Jul 2015 22:15:07 -0400 Subject: [PATCH] Add Pretty instances for Lists and pairs. --- src/Pretty.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Pretty.hs b/src/Pretty.hs index 84f9406..9115806 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 -- 2.43.2