on 9302221 help sign in
Idris-dev/src/Util/Pretty.hs
26 lines 539 B history raw
1module Util.Pretty (
2 module Text.PrettyPrint.Annotated.Leijen,
3 Sized(..), nestingSize,
4 Pretty(..)
5) where
7--import Text.PrettyPrint.HughesPJ
8import Text.PrettyPrint.Annotated.Leijen
10-- A rough notion of size for pretty printing various types.
11class Sized a where
12 size :: a -> Int
14instance (Sized a, Sized b) => Sized (a, b) where
15 size (left, right) = 1 + size left + size right
17instance Sized a => Sized [a] where
18 size = sum . map size
20nestingSize :: Int
21nestingSize = 1
23class Pretty a ty where
24 pretty :: a -> Doc ty