wl-pprint-text 1.0.0.0 → 1.1.0.0
raw patch · 3 files changed
+45/−7 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Text.PrettyPrint.Leijen.Text: instance IsString Doc
+ Text.PrettyPrint.Leijen.Text: instance Monoid Doc
+ Text.PrettyPrint.Leijen.Text: instance Show SimpleDoc
+ Text.PrettyPrint.Leijen.Text: renderOneLine :: Doc -> SimpleDoc
+ Text.PrettyPrint.Leijen.Text.Monadic: instance Monad m => IsString (m Doc)
+ Text.PrettyPrint.Leijen.Text.Monadic: renderOneLine :: Doc -> SimpleDoc
- Text.PrettyPrint.Leijen.Text: class Pretty a
+ Text.PrettyPrint.Leijen.Text: class Pretty a where prettyList = list . map pretty
- Text.PrettyPrint.Leijen.Text.Monadic: class Pretty a
+ Text.PrettyPrint.Leijen.Text.Monadic: class Pretty a where prettyList = list . map pretty
Files
- Text/PrettyPrint/Leijen/Text.hs +34/−3
- Text/PrettyPrint/Leijen/Text/Monadic.hs +10/−3
- wl-pprint-text.cabal +1/−1
Text/PrettyPrint/Leijen/Text.hs view
@@ -112,11 +112,12 @@ Pretty(..), -- * Rendering- SimpleDoc(..), renderPretty, renderCompact, displayT,- displayIO, putDoc, hPutDoc+ SimpleDoc(..), renderPretty, renderCompact, renderOneLine,+ displayT, displayIO, putDoc, hPutDoc ) where +import Data.String (IsString(fromString)) import System.IO (Handle,hPutStr,hPutChar,stdout) import qualified Data.Text.Lazy as T@@ -125,7 +126,7 @@ import qualified Data.Text.Lazy.Builder as B import Data.Text.Lazy.Builder(Builder) import Data.Int(Int64)-import Data.Monoid(mempty,mappend)+import Data.Monoid(Monoid(mempty,mappend)) infixr 5 </>,<//>,<$>,<$$> infixr 6 <>,<+>@@ -749,6 +750,13 @@ | Column (Int64 -> Doc) | Nesting (Int64 -> Doc) +instance IsString Doc where+ fromString = string . T.pack++instance Monoid Doc where+ mempty = empty+ mappend = beside+ -- | The data type @SimpleDoc@ represents rendered documents and is -- used by the display functions. --@@ -934,6 +942,25 @@ Column f -> scan k (f k:ds) Nesting f -> scan k (f 0:ds) +-- | @(renderOneLine x)@ renders document @x@ without adding any+-- indentation or newlines.+renderOneLine :: Doc -> SimpleDoc+renderOneLine x+ = scan 0 [x]+ where+ scan k [] = SEmpty+ scan k (d:ds)+ = case d of+ Empty -> scan k ds+ Char c -> let k' = k+1 in seq k' (SChar c (scan k' ds))+ Text l s -> let k' = k+l in seq k' (SText l s (scan k' ds))+ Line _ -> scan k ds+ Cat x y -> scan k (x:y:ds)+ Nest j x -> scan k (x:ds)+ Union x y -> scan k (y:ds)+ Column f -> scan k (f k:ds)+ Nesting f -> scan k (f 0:ds)+ ----------------------------------------------------------- -- Displayers: displayS and displayIO -----------------------------------------------------------@@ -981,6 +1008,10 @@ instance Show Doc where showsPrec d doc = showsPrec d (displayT $ renderPretty 0.4 80 doc)+ show doc = T.unpack (displayT $ renderPretty 0.4 80 doc)++instance Show SimpleDoc where+ show simpleDoc = T.unpack (displayT simpleDoc) -- | The action @(putDoc doc)@ pretty prints document @doc@ to the -- standard output, with a page width of 100 characters and a ribbon
Text/PrettyPrint/Leijen/Text/Monadic.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE FlexibleInstances #-}+ ----------------------------------------------------------------------------- -- | -- Module : Text.PrettyPrint.Leijen.Text.Monadic@@ -62,21 +64,26 @@ Pretty(..), prettyM, -- * Rendering- SimpleDoc(..), renderPretty, renderCompact, displayT,- displayIO, putDoc, hPutDoc+ SimpleDoc(..), renderPretty, renderCompact, renderOneLine,+ displayT, displayIO, putDoc, hPutDoc ) where import qualified Text.PrettyPrint.Leijen.Text as PP-import Text.PrettyPrint.Leijen.Text( Doc, SimpleDoc(..), renderPretty, renderCompact+import Text.PrettyPrint.Leijen.Text( Doc, SimpleDoc(..)+ , renderPretty, renderCompact, renderOneLine , displayT, displayIO, putDoc, hPutDoc, Pretty(..)) +import Data.String (IsString(fromString)) import Control.Monad(liftM, liftM2, liftM3, liftM4) import Data.Text.Lazy(Text) import Data.Int(Int64) infixr 5 </>,<//>,<$>,<$$> infixr 6 <>,<+>++instance Monad m => IsString (m Doc) where+ fromString = string . fromString -----------------------------------------------------------
wl-pprint-text.cabal view
@@ -1,5 +1,5 @@ Name: wl-pprint-text-Version: 1.0.0.0+Version: 1.1.0.0 Synopsis: A Wadler/Leijen Pretty Printer for Text values Description: A clone of wl-pprint for use with the text library. License: BSD3