packages feed

mainland-pretty 0.2.7.2 → 0.3.0.0

raw patch · 2 files changed

+87/−49 lines, 2 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

- Text.PrettyPrint.Mainland: instance (Integral a, Pretty a) => Pretty (Ratio a)
- Text.PrettyPrint.Mainland: instance (Pretty a, Pretty b) => Pretty (a, b)
- Text.PrettyPrint.Mainland: instance (Pretty a, Pretty b, Pretty c) => Pretty (a, b, c)
- Text.PrettyPrint.Mainland: instance (Pretty a, Pretty b, Pretty c, Pretty d) => Pretty (a, b, c, d)
- Text.PrettyPrint.Mainland: instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e) => Pretty (a, b, c, d, e)
- Text.PrettyPrint.Mainland: instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f) => Pretty (a, b, c, d, e, f)
- Text.PrettyPrint.Mainland: instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g) => Pretty (a, b, c, d, e, f, g)
- Text.PrettyPrint.Mainland: instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g, Pretty h) => Pretty (a, b, c, d, e, f, g, h)
- Text.PrettyPrint.Mainland: instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g, Pretty h, Pretty i) => Pretty (a, b, c, d, e, f, g, h, i)
- Text.PrettyPrint.Mainland: instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g, Pretty h, Pretty i, Pretty j) => Pretty (a, b, c, d, e, f, g, h, i, j)
- Text.PrettyPrint.Mainland: instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g, Pretty h, Pretty i, Pretty j, Pretty k) => Pretty (a, b, c, d, e, f, g, h, i, j, k)
- Text.PrettyPrint.Mainland: instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g, Pretty h, Pretty i, Pretty j, Pretty k, Pretty l) => Pretty (a, b, c, d, e, f, g, h, i, j, k, l)
- Text.PrettyPrint.Mainland: instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g, Pretty h, Pretty i, Pretty j, Pretty k, Pretty l, Pretty m) => Pretty (a, b, c, d, e, f, g, h, i, j, k, l, m)
- Text.PrettyPrint.Mainland: instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g, Pretty h, Pretty i, Pretty j, Pretty k, Pretty l, Pretty m, Pretty n) => Pretty (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
- Text.PrettyPrint.Mainland: instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g, Pretty h, Pretty i, Pretty j, Pretty k, Pretty l, Pretty m, Pretty n, Pretty o) => Pretty (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
- Text.PrettyPrint.Mainland: instance (Pretty k, Pretty v) => Pretty (Map k v)
- Text.PrettyPrint.Mainland: instance Monoid Doc
- Text.PrettyPrint.Mainland: instance Pretty ()
- Text.PrettyPrint.Mainland: instance Pretty Bool
- Text.PrettyPrint.Mainland: instance Pretty Char
- Text.PrettyPrint.Mainland: instance Pretty Double
- Text.PrettyPrint.Mainland: instance Pretty Float
- Text.PrettyPrint.Mainland: instance Pretty Int
- Text.PrettyPrint.Mainland: instance Pretty Int16
- Text.PrettyPrint.Mainland: instance Pretty Int32
- Text.PrettyPrint.Mainland: instance Pretty Int64
- Text.PrettyPrint.Mainland: instance Pretty Int8
- Text.PrettyPrint.Mainland: instance Pretty Integer
- Text.PrettyPrint.Mainland: instance Pretty Loc
- Text.PrettyPrint.Mainland: instance Pretty Pos
- Text.PrettyPrint.Mainland: instance Pretty Text
- Text.PrettyPrint.Mainland: instance Pretty Word16
- Text.PrettyPrint.Mainland: instance Pretty Word32
- Text.PrettyPrint.Mainland: instance Pretty Word64
- Text.PrettyPrint.Mainland: instance Pretty Word8
- Text.PrettyPrint.Mainland: instance Pretty a => Pretty (Maybe a)
- Text.PrettyPrint.Mainland: instance Pretty a => Pretty (Set a)
- Text.PrettyPrint.Mainland: instance Pretty a => Pretty [a]
- Text.PrettyPrint.Mainland: instance Pretty x => Pretty (L x)
- Text.PrettyPrint.Mainland: instance Show Doc
+ Text.PrettyPrint.Mainland: (<|>) :: Doc -> Doc -> Doc
+ Text.PrettyPrint.Mainland: instance (GHC.Real.Integral a, Text.PrettyPrint.Mainland.Pretty a) => Text.PrettyPrint.Mainland.Pretty (GHC.Real.Ratio a)
+ Text.PrettyPrint.Mainland: instance (Text.PrettyPrint.Mainland.Pretty a, Text.PrettyPrint.Mainland.Pretty b) => Text.PrettyPrint.Mainland.Pretty (a, b)
+ Text.PrettyPrint.Mainland: instance (Text.PrettyPrint.Mainland.Pretty a, Text.PrettyPrint.Mainland.Pretty b, Text.PrettyPrint.Mainland.Pretty c) => Text.PrettyPrint.Mainland.Pretty (a, b, c)
+ Text.PrettyPrint.Mainland: instance (Text.PrettyPrint.Mainland.Pretty a, Text.PrettyPrint.Mainland.Pretty b, Text.PrettyPrint.Mainland.Pretty c, Text.PrettyPrint.Mainland.Pretty d) => Text.PrettyPrint.Mainland.Pretty (a, b, c, d)
+ Text.PrettyPrint.Mainland: instance (Text.PrettyPrint.Mainland.Pretty a, Text.PrettyPrint.Mainland.Pretty b, Text.PrettyPrint.Mainland.Pretty c, Text.PrettyPrint.Mainland.Pretty d, Text.PrettyPrint.Mainland.Pretty e) => Text.PrettyPrint.Mainland.Pretty (a, b, c, d, e)
+ Text.PrettyPrint.Mainland: instance (Text.PrettyPrint.Mainland.Pretty a, Text.PrettyPrint.Mainland.Pretty b, Text.PrettyPrint.Mainland.Pretty c, Text.PrettyPrint.Mainland.Pretty d, Text.PrettyPrint.Mainland.Pretty e, Text.PrettyPrint.Mainland.Pretty f) => Text.PrettyPrint.Mainland.Pretty (a, b, c, d, e, f)
+ Text.PrettyPrint.Mainland: instance (Text.PrettyPrint.Mainland.Pretty a, Text.PrettyPrint.Mainland.Pretty b, Text.PrettyPrint.Mainland.Pretty c, Text.PrettyPrint.Mainland.Pretty d, Text.PrettyPrint.Mainland.Pretty e, Text.PrettyPrint.Mainland.Pretty f, Text.PrettyPrint.Mainland.Pretty g) => Text.PrettyPrint.Mainland.Pretty (a, b, c, d, e, f, g)
+ Text.PrettyPrint.Mainland: instance (Text.PrettyPrint.Mainland.Pretty a, Text.PrettyPrint.Mainland.Pretty b, Text.PrettyPrint.Mainland.Pretty c, Text.PrettyPrint.Mainland.Pretty d, Text.PrettyPrint.Mainland.Pretty e, Text.PrettyPrint.Mainland.Pretty f, Text.PrettyPrint.Mainland.Pretty g, Text.PrettyPrint.Mainland.Pretty h) => Text.PrettyPrint.Mainland.Pretty (a, b, c, d, e, f, g, h)
+ Text.PrettyPrint.Mainland: instance (Text.PrettyPrint.Mainland.Pretty a, Text.PrettyPrint.Mainland.Pretty b, Text.PrettyPrint.Mainland.Pretty c, Text.PrettyPrint.Mainland.Pretty d, Text.PrettyPrint.Mainland.Pretty e, Text.PrettyPrint.Mainland.Pretty f, Text.PrettyPrint.Mainland.Pretty g, Text.PrettyPrint.Mainland.Pretty h, Text.PrettyPrint.Mainland.Pretty i) => Text.PrettyPrint.Mainland.Pretty (a, b, c, d, e, f, g, h, i)
+ Text.PrettyPrint.Mainland: instance (Text.PrettyPrint.Mainland.Pretty a, Text.PrettyPrint.Mainland.Pretty b, Text.PrettyPrint.Mainland.Pretty c, Text.PrettyPrint.Mainland.Pretty d, Text.PrettyPrint.Mainland.Pretty e, Text.PrettyPrint.Mainland.Pretty f, Text.PrettyPrint.Mainland.Pretty g, Text.PrettyPrint.Mainland.Pretty h, Text.PrettyPrint.Mainland.Pretty i, Text.PrettyPrint.Mainland.Pretty j) => Text.PrettyPrint.Mainland.Pretty (a, b, c, d, e, f, g, h, i, j)
+ Text.PrettyPrint.Mainland: instance (Text.PrettyPrint.Mainland.Pretty a, Text.PrettyPrint.Mainland.Pretty b, Text.PrettyPrint.Mainland.Pretty c, Text.PrettyPrint.Mainland.Pretty d, Text.PrettyPrint.Mainland.Pretty e, Text.PrettyPrint.Mainland.Pretty f, Text.PrettyPrint.Mainland.Pretty g, Text.PrettyPrint.Mainland.Pretty h, Text.PrettyPrint.Mainland.Pretty i, Text.PrettyPrint.Mainland.Pretty j, Text.PrettyPrint.Mainland.Pretty k) => Text.PrettyPrint.Mainland.Pretty (a, b, c, d, e, f, g, h, i, j, k)
+ Text.PrettyPrint.Mainland: instance (Text.PrettyPrint.Mainland.Pretty a, Text.PrettyPrint.Mainland.Pretty b, Text.PrettyPrint.Mainland.Pretty c, Text.PrettyPrint.Mainland.Pretty d, Text.PrettyPrint.Mainland.Pretty e, Text.PrettyPrint.Mainland.Pretty f, Text.PrettyPrint.Mainland.Pretty g, Text.PrettyPrint.Mainland.Pretty h, Text.PrettyPrint.Mainland.Pretty i, Text.PrettyPrint.Mainland.Pretty j, Text.PrettyPrint.Mainland.Pretty k, Text.PrettyPrint.Mainland.Pretty l) => Text.PrettyPrint.Mainland.Pretty (a, b, c, d, e, f, g, h, i, j, k, l)
+ Text.PrettyPrint.Mainland: instance (Text.PrettyPrint.Mainland.Pretty a, Text.PrettyPrint.Mainland.Pretty b, Text.PrettyPrint.Mainland.Pretty c, Text.PrettyPrint.Mainland.Pretty d, Text.PrettyPrint.Mainland.Pretty e, Text.PrettyPrint.Mainland.Pretty f, Text.PrettyPrint.Mainland.Pretty g, Text.PrettyPrint.Mainland.Pretty h, Text.PrettyPrint.Mainland.Pretty i, Text.PrettyPrint.Mainland.Pretty j, Text.PrettyPrint.Mainland.Pretty k, Text.PrettyPrint.Mainland.Pretty l, Text.PrettyPrint.Mainland.Pretty m) => Text.PrettyPrint.Mainland.Pretty (a, b, c, d, e, f, g, h, i, j, k, l, m)
+ Text.PrettyPrint.Mainland: instance (Text.PrettyPrint.Mainland.Pretty a, Text.PrettyPrint.Mainland.Pretty b, Text.PrettyPrint.Mainland.Pretty c, Text.PrettyPrint.Mainland.Pretty d, Text.PrettyPrint.Mainland.Pretty e, Text.PrettyPrint.Mainland.Pretty f, Text.PrettyPrint.Mainland.Pretty g, Text.PrettyPrint.Mainland.Pretty h, Text.PrettyPrint.Mainland.Pretty i, Text.PrettyPrint.Mainland.Pretty j, Text.PrettyPrint.Mainland.Pretty k, Text.PrettyPrint.Mainland.Pretty l, Text.PrettyPrint.Mainland.Pretty m, Text.PrettyPrint.Mainland.Pretty n) => Text.PrettyPrint.Mainland.Pretty (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
+ Text.PrettyPrint.Mainland: instance (Text.PrettyPrint.Mainland.Pretty a, Text.PrettyPrint.Mainland.Pretty b, Text.PrettyPrint.Mainland.Pretty c, Text.PrettyPrint.Mainland.Pretty d, Text.PrettyPrint.Mainland.Pretty e, Text.PrettyPrint.Mainland.Pretty f, Text.PrettyPrint.Mainland.Pretty g, Text.PrettyPrint.Mainland.Pretty h, Text.PrettyPrint.Mainland.Pretty i, Text.PrettyPrint.Mainland.Pretty j, Text.PrettyPrint.Mainland.Pretty k, Text.PrettyPrint.Mainland.Pretty l, Text.PrettyPrint.Mainland.Pretty m, Text.PrettyPrint.Mainland.Pretty n, Text.PrettyPrint.Mainland.Pretty o) => Text.PrettyPrint.Mainland.Pretty (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
+ Text.PrettyPrint.Mainland: instance (Text.PrettyPrint.Mainland.Pretty k, Text.PrettyPrint.Mainland.Pretty v) => Text.PrettyPrint.Mainland.Pretty (Data.Map.Base.Map k v)
+ Text.PrettyPrint.Mainland: instance GHC.Base.Monoid Text.PrettyPrint.Mainland.Doc
+ Text.PrettyPrint.Mainland: instance GHC.Show.Show Text.PrettyPrint.Mainland.Doc
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty ()
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty Data.Loc.Loc
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty Data.Loc.Pos
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty Data.Text.Internal.Lazy.Text
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty Data.Text.Internal.Text
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty GHC.Int.Int16
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty GHC.Int.Int32
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty GHC.Int.Int64
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty GHC.Int.Int8
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty GHC.Integer.Type.Integer
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty GHC.Types.Bool
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty GHC.Types.Char
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty GHC.Types.Double
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty GHC.Types.Float
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty GHC.Types.Int
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty GHC.Word.Word16
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty GHC.Word.Word32
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty GHC.Word.Word64
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty GHC.Word.Word8
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty a => Text.PrettyPrint.Mainland.Pretty (Data.Set.Base.Set a)
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty a => Text.PrettyPrint.Mainland.Pretty (GHC.Base.Maybe a)
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty a => Text.PrettyPrint.Mainland.Pretty [a]
+ Text.PrettyPrint.Mainland: instance Text.PrettyPrint.Mainland.Pretty x => Text.PrettyPrint.Mainland.Pretty (Data.Loc.L x)

Files

Text/PrettyPrint/Mainland.hs view
@@ -33,7 +33,7 @@     softline, softbreak, group,      -- * Operators-    (<>), (<+>), (</>), (<+/>), (<//>),+    (<>), (<|>), (<+>), (</>), (<+/>), (<//>),      -- * Character documents     backquote, colon, comma, dot, dquote, equals, semi, space, spaces, squote,@@ -79,7 +79,11 @@                  posFile,                  posLine) import qualified Data.Map as Map+#if MIN_VERSION_base(4,5,0) import Data.Monoid (Monoid(..), (<>))+#else /* !MIN_VERSION_base(4,5,0) */+import Data.Monoid (Monoid(..))+#endif /* !MIN_VERSION_base(4,5,0) */ import qualified Data.Set as Set import qualified Data.Text as T import qualified Data.Text.Lazy.IO as TIO@@ -89,9 +93,6 @@ import GHC.Real (Ratio(..)) import System.IO (Handle) -infixr 5 </>, <+/>, <//>-infixr 6 <+>- data Doc = Empty                -- ^ The empty document          | Char Char            -- ^ A single character          | String !Int String   -- ^ 'String' with associated length (to avoid@@ -102,9 +103,8 @@          | Nest !Int Doc        -- ^ Indented document          | SrcLoc Loc           -- ^ Tag output with source location          | Doc `Cat` Doc        -- ^ Document concatenation-         | Doc `Alt` Doc        -- ^ Provide alternatives. Invariants: all-                                -- layouts of the two arguments flatten to the-                                -- same layout+         | Doc `Alt` Doc        -- ^ Provide alternatives. Invariant: both+                                -- arguments must flatten to the same document.          | Column  (Int -> Doc) -- ^ Calculate document based on current column          | Nesting (Int -> Doc) -- ^ Calculate document based on current nesting @@ -150,22 +150,34 @@ nest :: Int -> Doc -> Doc nest i d = Nest i d --- | The document @'srcloc' x@ adds the.+-- | The document @'srcloc' x@ tags the current line with @'locOf' x@. Only+-- shown when running 'prettyPragma' and friends. srcloc :: Located a => a -> Doc srcloc x = SrcLoc (locOf x) +-- | The document @'column' f@ is produced by calling @f@ with the current colum. column :: (Int -> Doc) -> Doc column = Column +-- | The document @'column' f@ is produced by calling @f@ with the+-- current nesting level. nesting :: (Int -> Doc) -> Doc nesting = Nesting +-- | Becomes 'space' if there is room, otherwise 'line'.+--+-- > pretty 11 $ text "foo" <+/> text "bar" <+/> text "baz" =="foo bar baz"+-- > pretty  7 $ text "foo" <+/> text "bar" <+/> text "baz" == "foo bar\nbaz"+-- > pretty  6 $ text "foo" <+/> text "bar" <+/> text "baz" == "foo\nbar\nbaz" softline :: Doc softline = space `Alt` line +-- | Becomes 'empty' if there is room, otherwise 'line'. softbreak :: Doc softbreak = empty `Alt` line +-- | The document @'group' d@ will flatten @d@ to /one/ line if there is+-- room for it, otherwise the original @d@. group :: Doc -> Doc group d = flatten d `Alt` d @@ -183,47 +195,69 @@ flatten (Column f)   = Column (flatten . f) flatten (Nesting f)  = Nesting (flatten . f) +#if !MIN_VERSION_base(4,5,0)+infixr 6 <>+#endif /* !MIN_VERSION_base(4,5,0) */+infixr 6 <+>+infixr 5 </>, <+/>, <//>+infixl 3 <|>++#if !MIN_VERSION_base(4,5,0)+-- | Concatenates two documents.+(<>) :: Doc -> Doc -> Doc+x <> y = x `Cat` y+#endif /* !MIN_VERSION_base(4,5,0) */++-- | Concatenates two documents with a 'space' in between. (<+>) :: Doc -> Doc -> Doc x <+> y = x <> space <> y +-- | Concatenates two documents with a 'line' in between. (</>) :: Doc -> Doc -> Doc x </> y = x <> line <> y +-- | Concatenates two documents with a 'softline' in between. (<+/>) :: Doc -> Doc -> Doc x <+/> y = x <> softline <> y +-- | Concatenates two documents with a 'softbreak' in between. (<//>) :: Doc -> Doc -> Doc x <//> y = x <> softbreak <> y --- | The document @backquote@ consists of a backquote, \"`\".+-- | Provide alternative layouts of the same content. Invariant: both arguments must+-- flatten to the same document.+(<|>) :: Doc -> Doc -> Doc+x <|> y = x `Alt` y++-- | The document @backquote@ consists of a backquote, @\"`\"@. backquote :: Doc backquote = char '`' --- | The document @colon@ consists of a colon, \":\".+-- | The document @colon@ consists of a colon, @\":\"@. colon :: Doc colon = char ':' --- | The document @comma@ consists of a comma, \",\".+-- | The document @comma@ consists of a comma, @\",\"@. comma :: Doc comma = char ',' --- | The document @dot@ consists of a period, \".\".+-- | The document @dot@ consists of a period, @\".\"@. dot :: Doc dot = char '.' --- | The document @dquote@ consists of a double quote, \"\\\"\".+-- | The document @dquote@ consists of a double quote, @\"\\\"\"@. dquote :: Doc dquote = char '"' --- | The document @equals@ consists of an equals sign, \"=\".+-- | The document @equals@ consists of an equals sign, @\"=\"@. equals :: Doc equals = char '=' --- | The document @semi@ consists of a semicolon, \";\".+-- | The document @semi@ consists of a semicolon, @\";\"@. semi :: Doc semi = char ';' --- | The document @space@ consists of a space, \" \".+-- | The document @space@ consists of a space, @\" \"@. space :: Doc space = char ' ' @@ -231,58 +265,58 @@ spaces :: Int -> Doc spaces n = text (replicate n ' ') --- | The document @squote@ consists of a single quote, \"\\'\".+-- | The document @squote@ consists of a single quote, @\"\\'\"@. squote :: Doc squote = char '\'' --- | The document @star@ consists of an asterisk, \"*\".+-- | The document @star@ consists of an asterisk, @\"*\"@. star :: Doc star = char '*' --- | The document @langle@ consists of a less-than sign, \"<\".+-- | The document @langle@ consists of a less-than sign, @\"<\"@. langle :: Doc langle = char '<' --- | The document @rangle@ consists of a greater-than sign, \">\".+-- | The document @rangle@ consists of a greater-than sign, @\">\"@. rangle :: Doc rangle = char '>' --- | The document @lbrace@ consists of a left brace, \"{\".+-- | The document @lbrace@ consists of a left brace, @\"{\"@. lbrace :: Doc lbrace = char '{' --- | The document @rbrace@ consists of a right brace, \"}\".+-- | The document @rbrace@ consists of a right brace, @\"}\"@. rbrace :: Doc rbrace = char '}' --- | The document @lbracket@ consists of a right brace, \"[\".+-- | The document @lbracket@ consists of a right brace, @\"[\"@. lbracket :: Doc lbracket = char '[' --- | The document @rbracket@ consists of a right brace, \"]\".+-- | The document @rbracket@ consists of a right brace, @\"]\"@. rbracket :: Doc rbracket = char ']' --- | The document @lparen@ consists of a right brace, \"(\".+-- | The document @lparen@ consists of a right brace, @\"(\"@. lparen :: Doc lparen = char '(' --- | The document @rparen@ consists of a right brace, \")\".+-- | The document @rparen@ consists of a right brace, @\")\"@. rparen :: Doc rparen = char ')' --- | The document @'enclose' l r d)@ encloses the document @d@ between the+-- | The document @'enclose' l r d@ encloses the document @d@ between the -- documents @l@ and @r@ using @<>@. It obeys the law -- -- @'enclose' l r d = l <> d <> r@ enclose :: Doc -> Doc -> Doc -> Doc enclose left right d = left <> d <> right --- | The document @'angles' d@ encloses the aligned document @d@ in <...>.+-- | The document @'angles' d@ encloses the aligned document @d@ in \<...\>. angles :: Doc -> Doc angles = enclose langle rangle . align --- | The document @'backquotes' d@ encloses the aligned document @d@ in `...`.+-- | The document @'backquotes' d@ encloses the aligned document @d@ in \`...\`. backquotes :: Doc -> Doc backquotes = enclose backquote backquote . align @@ -308,7 +342,7 @@ parensIf True doc  = parens doc parensIf False doc = doc --- | The document @'parens' d@ encloses the document @d@ in '...'.+-- | The document @'squotes' d@ encloses the alinged document @d@ in \'...\'. squotes :: Doc -> Doc squotes = enclose squote squote . align @@ -320,13 +354,12 @@           nest (k - i) d  -- | The document @'hang' i d@ renders @d@ with a nesting level set to the--- current column plus @i@. This differs from 'indent' in that the first line of--- @d@ /is not/ indented.+-- current column plus @i@, /not including/ the first line. hang :: Int -> Doc -> Doc hang i d = align (nest i d) --- | The document @'indent' i d@ indents @d@ @i@ spaces relative to the current--- column. This differs from 'hang' in that the first line of @d@ /is/ indented.+-- | The document @'indent' i d@ renders @d@ with a nesting level set to the+-- current column plus @i@, /including/ the first line. indent :: Int -> Doc -> Doc indent i d = align (nest i (spaces i <> d)) @@ -339,21 +372,21 @@ folddoc _ [x]    = x folddoc f (x:xs) = f x (folddoc f xs) --- | The document @'spread' ds@ concatenates the documents @ds@ using @<+>@.+-- | The document @'spread' ds@ concatenates the documents @ds@ with 'space'. spread :: [Doc] -> Doc spread = folddoc (<+>) --- | The document @'stack' ds@ concatenates the documents @ds@ using @</>@.+-- | The document @'stack' ds@ concatenates the documents @ds@ with 'line'. stack :: [Doc] -> Doc stack = folddoc (</>) --- | The document @'cat' ds@ separates the documents @ds@ with the empty--- document as long as there is room, and uses newlines when there isn't.+-- | The document @'cat' ds@ concatenates the documents @ds@ with the 'empty'+-- document as long as there is room, and uses 'line' when there isn't. cat :: [Doc] -> Doc cat = group . folddoc (<//>) --- | The document @'sep' ds@ separates the documents @ds@ with the empty--- document as long as there is room, and uses spaces when there isn't.+-- | The document @'sep' ds@ concatenates the documents @ds@ with the 'space'+-- document as long as there is room, and uses 'line' when there isn't. sep :: [Doc] -> Doc sep = group . folddoc (<+/>) @@ -406,7 +439,7 @@ tuple :: [Doc] -> Doc tuple = encloseSep lparen rparen comma --- | The document @'tuple' ds@ separates @ds@ with commas and encloses them with+-- | The document @'list' ds@ separates @ds@ with commas and encloses them with -- brackets. list :: [Doc] -> Doc list = encloseSep lbracket rbracket comma@@ -491,6 +524,18 @@ prettyPragmaS w x = displayPragmaS (render w x)  -- | Render and convert a document to a 'String' with #line pragmas.+--+-- > > let loc = Loc (Pos "filename" 3 5 7) (Pos "filename" 5 7 9)+-- > > in  putStrLn $ prettyPragma 80 $ srcloc loc <> text "foo" </> text "bar" </> text "baz"+--+-- will be printed as+--+-- @+-- foo+-- #line 3 "filename"+-- bar+-- baz+-- @ prettyPragma :: Int -> Doc -> String prettyPragma w x = prettyPragmaS w x "" @@ -625,13 +670,6 @@ -- | Render a document with a width of 80 and print it to the specified handle. hPutDoc :: Handle -> Doc -> IO () hPutDoc h = TIO.hPutStr h . prettyLazyText 80--#if !MIN_VERSION_base(4,5,0)-infixr 6 <>--(<>) :: Doc -> Doc -> Doc-x <> y = x `Cat` y-#endif /* !MIN_VERSION_base(4,5,0) */  instance Monoid Doc where     mempty  = empty
mainland-pretty.cabal view
@@ -1,5 +1,5 @@ name:           mainland-pretty-version:        0.2.7.2+version:        0.3.0.0 cabal-version:  >= 1.6 license:        BSD3 license-file:   LICENSE