on 0c8a486 help sign in
Idris-dev/src/Util/Pretty.hs
32 lines 692 B history raw
1{-|
2Module : Util.Pretty
3Description : Utilities for Pretty Printing.
4Copyright :
5License : BSD3
6Maintainer : The Idris Community.
7-}
8module Util.Pretty (
9 module Text.PrettyPrint.Annotated.Leijen
10 , Sized(..)
11 , nestingSize
12 , Pretty(..)
13 ) where
15--import Text.PrettyPrint.HughesPJ
16import Text.PrettyPrint.Annotated.Leijen
18-- A rough notion of size for pretty printing various types.
19class Sized a where
20 size :: a -> Int
22instance (Sized a, Sized b) => Sized (a, b) where
23 size (left, right) = 1 + size left + size right
25instance Sized a => Sized [a] where
26 size = sum . map size
28nestingSize :: Int
29nestingSize = 1
31class Pretty a ty where
32 pretty :: a -> Doc ty