on 3cb1f21 help sign in
Idris-dev/src/Util/Pretty.hs
30 lines 648 B history raw
1module Util.Pretty (
2 module Text.PrettyPrint.Annotated.Leijen,
3 Sized(..), breakingSize, 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
20-- The maximum size before we break on to another line.
21breakingSize :: Int
22breakingSize = 15
24nestingSize :: Int
25nestingSize = 1
27class Pretty a ty where
28 pretty :: a -> Doc ty