module Util.Pretty (
module Text.PrettyPrint.HughesPJ,
Sized(..), breakingSize, nestingSize,
Pretty(..)
) where
import Text.PrettyPrint.HughesPJ
class Sized a where
size :: a -> Int
instance (Sized a, Sized b) => Sized (a, b) where
size (left, right) = 1 + size left + size right
instance Sized a => Sized [a] where
size = sum . map size
breakingSize :: Int
breakingSize = 15
nestingSize :: Int
nestingSize = 1
class Pretty a where
pretty :: a -> Doc
instance Pretty () where
pretty () = text "()"
instance Pretty a => Pretty [a] where
pretty l = foldr ($$) empty $ map pretty l