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