Added a file for pretty printing arbitrary data types.
commita34b377eceba7ac4fc79fe3745119f383a7e2ceb
authorDominic Mulligan <dominic.p.mulligan@googlemail.com>
dateMon 27 Feb 2012, 09:59 (15 years ago)
parent0818a58
src/Util/Pretty.hsnew file+18
@@ -0,0 +1,18 @@
1+module Util.Pretty (
2+ module Text.PrettyPrint.HughesPJ,
3+ Sized(..), Pretty(..)
4+) where
5+
6+import Text.PrettyPrint.HughesPJ
7+
8+class Sized a where
9+ size :: a -> Int
10+
11+instance (Sized a, Sized b) => Sized (a, b) where
12+ size (left, right) = 1 + size left + size right
13+
14+instance Sized a => Sized [a] where
15+ size = sum . map size
16+
17+class Pretty a where
18+ pretty :: a -> Doc