prettyprinter 1.7.0 → 1.7.1
raw patch · 31 files changed
+197/−164 lines, 31 filesdep ~bytestring
Dependency ranges changed: bytestring
Files
- CHANGELOG.md +13/−0
- README.md +0/−5
- app/GenerateReadme.hs +2/−2
- bench/FasterUnsafeText.hs +3/−3
- bench/Fusion.hs +3/−3
- bench/LargeOutput.hs +2/−2
- prettyprinter.cabal +37/−10
- src-text/Data/Text.hs +46/−0
- src-text/Data/Text/IO.hs +13/−0
- src-text/Data/Text/Lazy.hs +15/−0
- src-text/Data/Text/Lazy/Builder.hs +13/−0
- src/Data/Text/Prettyprint/Doc.hs +1/−8
- src/Data/Text/Prettyprint/Doc/Internal.hs +1/−8
- src/Data/Text/Prettyprint/Doc/Internal/Debug.hs +1/−8
- src/Data/Text/Prettyprint/Doc/Internal/Type.hs +1/−8
- src/Data/Text/Prettyprint/Doc/Render/String.hs +1/−8
- src/Data/Text/Prettyprint/Doc/Render/Text.hs +1/−8
- src/Data/Text/Prettyprint/Doc/Render/Tutorials/StackMachineTutorial.hs +1/−8
- src/Data/Text/Prettyprint/Doc/Render/Tutorials/TreeRenderingTutorial.hs +1/−8
- src/Data/Text/Prettyprint/Doc/Render/Util/Panic.hs +1/−8
- src/Data/Text/Prettyprint/Doc/Render/Util/SimpleDocTree.hs +1/−8
- src/Data/Text/Prettyprint/Doc/Render/Util/StackMachine.hs +1/−8
- src/Data/Text/Prettyprint/Doc/Symbols/Ascii.hs +1/−8
- src/Data/Text/Prettyprint/Doc/Symbols/Unicode.hs +1/−8
- src/Data/Text/Prettyprint/Doc/Util.hs +1/−8
- src/Prettyprinter.hs +6/−3
- src/Prettyprinter/Internal.hs +22/−16
- src/Prettyprinter/Render/Text.hs +2/−1
- src/Prettyprinter/Render/Util/SimpleDocTree.hs +0/−1
- test/Testsuite/Main.hs +4/−4
- test/Testsuite/StripTrailingSpace.hs +2/−2
CHANGELOG.md view
@@ -1,3 +1,16 @@+# [1.7.1]++- [Deprecate the `Data.Text.Prettyprint.*` modules](https://github.com/quchen/prettyprinter/pull/203)+ * Users should migrate to the new `Prettyprinter` module hierarchy.+ * The old modules will be removed no sooner than September 2022.+- [Make `text` an optional dependency:](https://github.com/quchen/prettyprinter/pull/202)+ * When built with `-f-text`, any `text`-based APIs will operate on `String`s instead.+- Documentation improvements:+ * [#194](https://github.com/quchen/prettyprinter/pull/194)+ * [`1f0bffe`](https://github.com/quchen/prettyprinter/commit/1f0bffe5eb53874d1ba46b0a80bda67c02365f1b)++[1.7.1]: https://github.com/quchen/prettyprinter/compare/v1.7.0...v1.7.1+ # [1.7.0] ## Breaking changes
README.md view
@@ -5,12 +5,7 @@ A modern Wadler/Leijen Prettyprinter ==================================== -[](https://travis-ci.org/quchen/prettyprinter) [](https://hackage.haskell.org/package/prettyprinter)-[](https://www.stackage.org/package/prettyprinter)-[](https://www.stackage.org/package/prettyprinter)-- tl;dr -----
app/GenerateReadme.hs view
@@ -11,8 +11,8 @@ import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.IO as T-import Data.Text.Prettyprint.Doc-import Data.Text.Prettyprint.Doc.Render.Text+import Prettyprinter+import Prettyprinter.Render.Text import MultilineTh
bench/FasterUnsafeText.hs view
@@ -6,9 +6,9 @@ import Gauge.Main import Data.Char-import Data.Text (Text)-import qualified Data.Text as T-import Data.Text.Prettyprint.Doc.Internal+import Data.Text (Text)+import qualified Data.Text as T+import Prettyprinter.Internal
bench/Fusion.hs view
@@ -14,9 +14,9 @@ import qualified Data.Text as T import System.Random -import Data.Text.Prettyprint.Doc-import Data.Text.Prettyprint.Doc.Render.Text-import qualified Text.PrettyPrint.ANSI.Leijen as WL+import Prettyprinter+import Prettyprinter.Render.Text+import qualified Text.PrettyPrint.ANSI.Leijen as WL #if !(APPLICATIVE_MONAD) import Control.Applicative
bench/LargeOutput.hs view
@@ -18,8 +18,8 @@ import qualified Data.Text as T import qualified Data.Text.IO as T import qualified Data.Text.Lazy as TL-import Data.Text.Prettyprint.Doc-import Data.Text.Prettyprint.Doc.Render.Text+import Prettyprinter+import Prettyprinter.Render.Text import GHC.Generics import Test.QuickCheck import Test.QuickCheck.Gen
prettyprinter.cabal view
@@ -1,5 +1,5 @@ name: prettyprinter-version: 1.7.0+version: 1.7.1 cabal-version: >= 1.10 category: User Interfaces, Text synopsis: A modern, easy to use, well-documented, extensible pretty-printer.@@ -9,13 +9,12 @@ extra-source-files: README.md , CHANGELOG.md , misc/version-compatibility-macros.h-author: Phil Wadler, Daan Leijen, Max Bolingbroke, Edward Kmett, David Luposchainsky+author: Phil Wadler, Daan Leijen, Max Bolingbroke, Edward Kmett, David Luposchainsky, Simon Jakobi maintainer: Simon Jakobi <simon.jakobi@gmail.com>, David Luposchainsky <dluposchainsky at google> bug-reports: http://github.com/quchen/prettyprinter/issues homepage: http://github.com/quchen/prettyprinter build-type: Simple--+tested-with: GHC==9.0.1, GHC==8.10.4, GHC==8.8.4, GHC==8.6.5, GHC==8.4.4, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2 source-repository head type: git@@ -70,8 +69,18 @@ build-depends: base >= 4.5 && < 5- , text >= 1.2 + if flag(text)+ build-depends: text >= 1.2+ else+ -- A fake text package, emulating the same API, but backed by String+ hs-source-dirs: src-text+ other-modules:+ Data.Text+ , Data.Text.IO+ , Data.Text.Lazy+ , Data.Text.Lazy.Builder+ if !impl(ghc >= 7.6) build-depends: ghc-prim @@ -89,7 +98,15 @@ Description: Build the readme generator Default: False +Flag text+ Description: While it's a core value of @prettyprinter@ to use @Text@, there are rare+ circumstances (mostly when @prettyprinter@ arises as a dependency of+ test suites of packages like @bytestring@ or @text@ themselves) when+ this is inconvenient. In this case one can disable this flag, so that+ @prettyprinter@ fallbacks to @String@.+ Default: True + executable generate_readme hs-source-dirs: app main-is: GenerateReadme.hs@@ -104,7 +121,7 @@ other-extensions: OverloadedStrings , TemplateHaskell , QuasiQuotes- if flag(buildReadme)+ if flag(buildReadme) && flag(text) buildable: True else buildable: False@@ -136,7 +153,7 @@ , prettyprinter , pgp-wordlist >= 0.1- , bytestring >= 0.10+ , bytestring , quickcheck-instances >= 0.3 , tasty >= 0.10 , tasty-hunit >= 0.9@@ -148,6 +165,8 @@ if !impl(ghc >= 8.0) build-depends: semigroups >= 0.6 + if !flag(text)+ buildable: False benchmark fusion@@ -164,10 +183,13 @@ , text , transformers >= 0.3 , ansi-wl-pprint >= 0.6- ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N+ ghc-options: -Wall -rtsopts default-language: Haskell2010 other-extensions: OverloadedStrings + if !flag(text)+ buildable: False+ benchmark faster-unsafe-text build-depends: base >= 4.5 && < 5@@ -178,10 +200,12 @@ hs-source-dirs: bench main-is: FasterUnsafeText.hs- ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall+ ghc-options: -rtsopts -Wall default-language: Haskell2010 type: exitcode-stdio-1.0 + if !flag(text)+ buildable: False benchmark large-output build-depends:@@ -198,7 +222,7 @@ hs-source-dirs: bench main-is: LargeOutput.hs- ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall+ ghc-options: -rtsopts -Wall default-language: Haskell2010 type: exitcode-stdio-1.0 @@ -207,3 +231,6 @@ if !impl(ghc >= 8.0) build-depends: semigroups++ if !flag(text)+ buildable: False
+ src-text/Data/Text.hs view
@@ -0,0 +1,46 @@+-- Provide a fake API, mimicking Data.Text from text package,+-- but actually backed by type Text = String. It is used only in rare+-- circumstances, when prettyprinter is built with -text flag.+--++{-# OPTIONS_GHC -fno-warn-missing-signatures #-}++module Data.Text where++import Prelude hiding (head, length, null, replicate)+import qualified Data.Char+import qualified Data.List++type Text = String+cons = (:)+dropWhileEnd = Data.List.dropWhileEnd+head = Data.List.head+intercalate = Data.List.intercalate+length = Data.List.length :: [Char] -> Int+lines = Data.List.lines+map = Data.List.map+null = Data.List.null :: [Char] -> Bool+pack = id+replicate = (Data.List.concat .) . Data.List.replicate+singleton = (:[])+snoc xs x = xs ++ [x]+stripEnd = dropWhileEnd Data.Char.isSpace+unlines = Data.List.unlines+unpack = id+words = Data.List.words++uncons :: Text -> Maybe (Char, Text)+uncons [] = Nothing+uncons (x : xs) = Just (x, xs)++splitOn :: Text -> Text -> [Text]+splitOn pat src+ | null pat = error "splitOn: empty pattern"+ | otherwise = go [] src+ where+ go acc [] = [reverse acc]+ go acc xs@(y : ys)+ | pat `Data.List.isPrefixOf` xs+ = reverse acc : go [] (drop (length pat) xs)+ | otherwise+ = go (y : acc) ys
+ src-text/Data/Text/IO.hs view
@@ -0,0 +1,13 @@+-- Provide a fake API, mimicking Data.Text.IO from text package,+-- but actually backed by type Text = String. It is used only in rare+-- circumstances, when prettyprinter is built with -text flag.+--++{-# OPTIONS_GHC -fno-warn-missing-signatures #-}++module Data.Text.IO where++import qualified System.IO++hPutStr = System.IO.hPutStr+putStrLn = System.IO.putStrLn
+ src-text/Data/Text/Lazy.hs view
@@ -0,0 +1,15 @@+-- Provide a fake API, mimicking Data.Text.Lazy from text package,+-- but actually backed by type Text = String. It is used only in rare+-- circumstances, when prettyprinter is built with -text flag.+--++{-# OPTIONS_GHC -fno-warn-missing-signatures #-}++module Data.Text.Lazy where++import Data.Text as T++type Text = T.Text+length = T.length+lines = T.lines+toStrict = id
+ src-text/Data/Text/Lazy/Builder.hs view
@@ -0,0 +1,13 @@+-- Provide a fake API, mimicking Data.Text.Lazy.Builder from text package,+-- but actually backed by type Builder = String. It is used only in rare+-- circumstances, when prettyprinter is built with -text flag.+--++{-# OPTIONS_GHC -fno-warn-missing-signatures #-}++module Data.Text.Lazy.Builder where++type Builder = String+fromText = id+singleton = (:[])+toLazyText = id
src/Data/Text/Prettyprint/Doc.hs view
@@ -1,11 +1,4 @@--- | This module is part of the old @Data.Text.Prettyprint.Doc@ module hierarchy--- which is being replaced by a shallower @Prettyprinter@ module hierarchy--- offering the same API.------ This module will be deprecated and eventually removed.------ Use "Prettyprinter" instead.-module Data.Text.Prettyprint.Doc (+module Data.Text.Prettyprint.Doc {-# DEPRECATED "Use \"Prettyprinter\" instead." #-} ( module Prettyprinter ) where
src/Data/Text/Prettyprint/Doc/Internal.hs view
@@ -1,11 +1,4 @@--- | This module is part of the old @Data.Text.Prettyprint.Doc@ module hierarchy--- which is being replaced by a shallower @Prettyprinter@ module hierarchy--- offering the same API.------ This module will be deprecated and eventually removed.------ Use "Prettyprinter.Internal" instead.-module Data.Text.Prettyprint.Doc.Internal (+module Data.Text.Prettyprint.Doc.Internal {-# DEPRECATED "Use \"Prettyprinter.Internal\" instead." #-} ( module Prettyprinter.Internal ) where
src/Data/Text/Prettyprint/Doc/Internal/Debug.hs view
@@ -1,11 +1,4 @@--- | This module is part of the old @Data.Text.Prettyprint.Doc@ module hierarchy--- which is being replaced by a shallower @Prettyprinter@ module hierarchy--- offering the same API.------ This module will be deprecated and eventually removed.------ Use "Prettyprinter.Internal.Debug" instead.-module Data.Text.Prettyprint.Doc.Internal.Debug (+module Data.Text.Prettyprint.Doc.Internal.Debug {-# DEPRECATED "Use \"Prettyprinter.Internal.Debug\" instead." #-} ( module Prettyprinter.Internal.Debug ) where
src/Data/Text/Prettyprint/Doc/Internal/Type.hs view
@@ -1,11 +1,4 @@--- | This module is part of the old @Data.Text.Prettyprint.Doc@ module hierarchy--- which is being replaced by a shallower @Prettyprinter@ module hierarchy--- offering the same API.------ This module will be deprecated and eventually removed.------ Use "Prettyprinter.Internal.Type" instead.-module Data.Text.Prettyprint.Doc.Internal.Type (+module Data.Text.Prettyprint.Doc.Internal.Type {-# DEPRECATED "Use \"Prettyprinter.Internal.Type\" instead." #-} ( module Prettyprinter.Internal.Type ) where
src/Data/Text/Prettyprint/Doc/Render/String.hs view
@@ -1,11 +1,4 @@--- | This module is part of the old @Data.Text.Prettyprint.Doc@ module hierarchy--- which is being replaced by a shallower @Prettyprinter@ module hierarchy--- offering the same API.------ This module will be deprecated and eventually removed.------ Use "Prettyprinter.Render.String" instead.-module Data.Text.Prettyprint.Doc.Render.String (+module Data.Text.Prettyprint.Doc.Render.String {-# DEPRECATED "Use \"Prettyprinter.Render.String\" instead." #-} ( module Prettyprinter.Render.String ) where
src/Data/Text/Prettyprint/Doc/Render/Text.hs view
@@ -1,11 +1,4 @@--- | This module is part of the old @Data.Text.Prettyprint.Doc@ module hierarchy--- which is being replaced by a shallower @Prettyprinter@ module hierarchy--- offering the same API.------ This module will be deprecated and eventually removed.------ Use "Prettyprinter.Render.Text" instead.-module Data.Text.Prettyprint.Doc.Render.Text (+module Data.Text.Prettyprint.Doc.Render.Text {-# DEPRECATED "Use \"Prettyprinter.Render.Text\" instead." #-} ( module Prettyprinter.Render.Text ) where
src/Data/Text/Prettyprint/Doc/Render/Tutorials/StackMachineTutorial.hs view
@@ -1,11 +1,4 @@--- | This module is part of the old @Data.Text.Prettyprint.Doc@ module hierarchy--- which is being replaced by a shallower @Prettyprinter@ module hierarchy--- offering the same API.------ This module will be deprecated and eventually removed.------ Use "Prettyprinter.Render.Tutorials.StackMachineTutorial" instead.-module Data.Text.Prettyprint.Doc.Render.Tutorials.StackMachineTutorial (+module Data.Text.Prettyprint.Doc.Render.Tutorials.StackMachineTutorial {-# DEPRECATED "Use \"Prettyprinter.Render.Tutorials.StackMachineTutorial\" instead." #-} ( module Prettyprinter.Render.Tutorials.StackMachineTutorial ) where
src/Data/Text/Prettyprint/Doc/Render/Tutorials/TreeRenderingTutorial.hs view
@@ -1,11 +1,4 @@--- | This module is part of the old @Data.Text.Prettyprint.Doc@ module hierarchy--- which is being replaced by a shallower @Prettyprinter@ module hierarchy--- offering the same API.------ This module will be deprecated and eventually removed.------ Use "Prettyprinter.Render.Tutorials.TreeRenderingTutorial" instead.-module Data.Text.Prettyprint.Doc.Render.Tutorials.TreeRenderingTutorial (+module Data.Text.Prettyprint.Doc.Render.Tutorials.TreeRenderingTutorial {-# DEPRECATED "Use \"Prettyprinter.Render.Tutorials.TreeRenderingTutorial\" instead." #-} ( module Prettyprinter.Render.Tutorials.TreeRenderingTutorial ) where
src/Data/Text/Prettyprint/Doc/Render/Util/Panic.hs view
@@ -1,11 +1,4 @@--- | This module is part of the old @Data.Text.Prettyprint.Doc@ module hierarchy--- which is being replaced by a shallower @Prettyprinter@ module hierarchy--- offering the same API.------ This module will be deprecated and eventually removed.------ Use "Prettyprinter.Render.Util.Panic" instead.-module Data.Text.Prettyprint.Doc.Render.Util.Panic (+module Data.Text.Prettyprint.Doc.Render.Util.Panic {-# DEPRECATED "Use \"Prettyprinter.Render.Util.Panic\" instead." #-} ( module Prettyprinter.Render.Util.Panic ) where
src/Data/Text/Prettyprint/Doc/Render/Util/SimpleDocTree.hs view
@@ -1,11 +1,4 @@--- | This module is part of the old @Data.Text.Prettyprint.Doc@ module hierarchy--- which is being replaced by a shallower @Prettyprinter@ module hierarchy--- offering the same API.------ This module will be deprecated and eventually removed.------ Use "Prettyprinter.Render.Util.SimpleDocTree" instead.-module Data.Text.Prettyprint.Doc.Render.Util.SimpleDocTree (+module Data.Text.Prettyprint.Doc.Render.Util.SimpleDocTree {-# DEPRECATED "Use \"Prettyprinter.Render.Util.SimpleDocTree\" instead." #-} ( module Prettyprinter.Render.Util.SimpleDocTree ) where
src/Data/Text/Prettyprint/Doc/Render/Util/StackMachine.hs view
@@ -1,11 +1,4 @@--- | This module is part of the old @Data.Text.Prettyprint.Doc@ module hierarchy--- which is being replaced by a shallower @Prettyprinter@ module hierarchy--- offering the same API.------ This module will be deprecated and eventually removed.------ Use "Prettyprinter.Render.Util.StackMachine" instead.-module Data.Text.Prettyprint.Doc.Render.Util.StackMachine (+module Data.Text.Prettyprint.Doc.Render.Util.StackMachine {-# DEPRECATED "Use \"Prettyprinter.Render.Util.StackMachine\" instead." #-} ( module Prettyprinter.Render.Util.StackMachine ) where
src/Data/Text/Prettyprint/Doc/Symbols/Ascii.hs view
@@ -1,11 +1,4 @@--- | This module is part of the old @Data.Text.Prettyprint.Doc@ module hierarchy--- which is being replaced by a shallower @Prettyprinter@ module hierarchy--- offering the same API.------ This module will be deprecated and eventually removed.------ Use "Prettyprinter.Symbols.Ascii" instead.-module Data.Text.Prettyprint.Doc.Symbols.Ascii (+module Data.Text.Prettyprint.Doc.Symbols.Ascii {-# DEPRECATED "Use \"Prettyprinter.Symbols.Ascii\" instead." #-} ( module Prettyprinter.Symbols.Ascii ) where
src/Data/Text/Prettyprint/Doc/Symbols/Unicode.hs view
@@ -1,11 +1,4 @@--- | This module is part of the old @Data.Text.Prettyprint.Doc@ module hierarchy--- which is being replaced by a shallower @Prettyprinter@ module hierarchy--- offering the same API.------ This module will be deprecated and eventually removed.------ Use "Prettyprinter.Symbols.Unicode" instead.-module Data.Text.Prettyprint.Doc.Symbols.Unicode (+module Data.Text.Prettyprint.Doc.Symbols.Unicode {-# DEPRECATED "Use \"Prettyprinter.Symbols.Unicode\" instead." #-} ( module Prettyprinter.Symbols.Unicode ) where
src/Data/Text/Prettyprint/Doc/Util.hs view
@@ -1,11 +1,4 @@--- | This module is part of the old @Data.Text.Prettyprint.Doc@ module hierarchy--- which is being replaced by a shallower @Prettyprinter@ module hierarchy--- offering the same API.------ This module will be deprecated and eventually removed.------ Use "Prettyprinter.Util" instead.-module Data.Text.Prettyprint.Doc.Util (+module Data.Text.Prettyprint.Doc.Util {-# DEPRECATED "Use \"Prettyprinter.Util\" instead." #-} ( module Prettyprinter.Util ) where
src/Prettyprinter.hs view
@@ -38,7 +38,10 @@ -- Let’s prettyprint a simple Haskell type definition. First, intersperse @->@ -- and add a leading @::@, ----- >>> let prettyType = align . sep . zipWith (<+>) ("::" : repeat "->")+-- >>> :{+-- >>> prettyprintType :: [Doc x] -> Doc x+-- >>> prettyprintType = align . sep . zipWith (<+>) ("::" : repeat "->")+-- >>> :} -- -- The 'sep' function is one way of concatenating documents, there are multiple -- others, e.g. 'vsep', 'cat' and 'fillSep'. In our case, 'sep' space-separates@@ -47,11 +50,11 @@ -- -- Second, prepend the name to the type, ----- >>> let prettyDecl n tys = pretty n <+> prettyType tys+-- >>> let prettyprintDeclaration n tys = pretty n <+> prettyprintType tys -- -- Now we can define a document that contains some type signature: ----- >>> let doc = prettyDecl "example" ["Int", "Bool", "Char", "IO ()"]+-- >>> let doc = prettyprintDeclaration "example" ["Int", "Bool", "Char", "IO ()"] -- -- This document can now be printed, and it automatically adapts to available -- space. If the page is wide enough (80 characters in this case), the
src/Prettyprinter/Internal.hs view
@@ -315,7 +315,7 @@ -- | >>> pretty () -- () ----- The argument is not used,+-- The argument is not used: -- -- >>> pretty (error "Strict?" :: ()) -- ()@@ -339,7 +339,11 @@ pretty '\n' = line pretty c = Char c +#ifdef MIN_VERSION_text prettyList = pretty . (id :: Text -> Text) . fromString+#else+ prettyList = vsep . map unsafeTextWithoutNewlines . T.splitOn "\n"+#endif -- | Convenience function to convert a 'Show'able value to a 'Doc'. If the -- 'String' does not contain newlines, consider using the more performant@@ -435,6 +439,7 @@ pretty = maybe mempty pretty prettyList = prettyList . catMaybes +#ifdef MIN_VERSION_text -- | Automatically converts all newlines to @'line'@. -- -- >>> pretty ("hello\nworld" :: Text)@@ -451,6 +456,7 @@ -- | (lazy 'Text' instance, identical to the strict version) instance Pretty Lazy.Text where pretty = pretty . Lazy.toStrict+#endif -- | Finding a good example for printing something that does not exist is hard, -- so here is an example of printing a list full of nothing.@@ -732,13 +738,13 @@ -- >>> let prettyDo xs = group ("do" <+> align (encloseSep open close separator xs)) -- >>> let statements = ["name:_ <- getArgs", "let greet = \"Hello, \" <> name", "putStrLn greet"] ----- This is put into a single line with @{;}@ style if it fits,+-- This is put into a single line with @{;}@ style if it fits: -- -- >>> putDocW 80 (prettyDo statements) -- do { name:_ <- getArgs; let greet = "Hello, " <> name; putStrLn greet } -- -- When there is not enough space the statements are broken up into lines--- nicely,+-- nicely: -- -- >>> putDocW 10 (prettyDo statements) -- do name:_ <- getArgs@@ -778,14 +784,14 @@ -- -- As an example, we will put a document right above another one, regardless of -- the current nesting level. Without 'align'ment, the second line is put simply--- below everything we've had so far,+-- below everything we've had so far: -- -- >>> "lorem" <+> vsep ["ipsum", "dolor"] -- lorem ipsum -- dolor -- -- If we add an 'align' to the mix, the @'vsep'@'s contents all start in the--- same column,+-- same column: -- -- >>> "lorem" <+> align (vsep ["ipsum", "dolor"]) -- lorem ipsum@@ -843,7 +849,7 @@ -- | @('encloseSep' l r sep xs)@ concatenates the documents @xs@ separated by -- @sep@, and encloses the resulting document by @l@ and @r@. ----- The documents are laid out horizontally if that fits the page,+-- The documents are laid out horizontally if that fits the page: -- -- >>> let doc = "list" <+> align (encloseSep lbracket rbracket comma (map pretty [1,20,300,4000])) -- >>> putDocW 80 doc@@ -934,15 +940,15 @@ -- 'concatWith' (**) [x,y,z] = x ** y ** z -- @ ----- Multiple convenience definitions based on 'concatWith' are alredy predefined,--- for example+-- Multiple convenience definitions based on 'concatWith' are already predefined,+-- for example: -- -- @ -- 'hsep' = 'concatWith' ('<+>') -- 'fillSep' = 'concatWith' (\\x y -> x '<>' 'softline' '<>' y) -- @ ----- This is also useful to define customized joiners,+-- This is also useful to define customized joiners: -- -- >>> concatWith (surround dot) ["Prettyprinter", "Render", "Text"] -- Prettyprinter.Render.Text@@ -1092,7 +1098,7 @@ -- instead of newlines. See 'fillSep' if you want a 'space' instead.) -- -- Observe the difference between 'fillSep' and 'fillCat'. 'fillSep'--- concatenates the entries 'space'd when 'group'ed,+-- concatenates the entries 'space'd when 'group'ed: -- -- >>> let docs = take 20 (cycle (["lorem", "ipsum", "dolor", "sit", "amet"])) -- >>> putDocW 40 ("Grouped:" <+> group (fillSep docs))@@ -1102,7 +1108,7 @@ -- amet -- -- On the other hand, 'fillCat' concatenates the entries directly when--- 'group'ed,+-- 'group'ed: -- -- >>> putDocW 40 ("Grouped:" <+> group (fillCat docs)) -- Grouped: loremipsumdolorsitametlorem@@ -1120,7 +1126,7 @@ -- >>> putDocW 80 ("Docs:" <+> cat docs) -- Docs: loremipsumdolor ----- When there is enough space, the documents are put above one another,+-- When there is enough space, the documents are put above one another: -- -- >>> putDocW 10 ("Docs:" <+> cat docs) -- Docs: lorem@@ -1364,7 +1370,7 @@ -- | Change the annotation of a 'Doc'ument. -- -- Useful in particular to embed documents with one form of annotation in a more--- generlly annotated document.+-- generally annotated document. -- -- Since this traverses the entire @'Doc'@ tree, including parts that are not -- rendered due to other layouts fitting better, it is preferrable to reannotate@@ -1511,7 +1517,7 @@ -- which is only a single 'SimpleDocStream' entry, and can be processed faster. -- -- It is therefore a good idea to run 'fuse' on concatenations of lots of small--- strings that are used many times,+-- strings that are used many times: -- -- >>> let oftenUsed = fuse Shallow ("a" <> "b" <> pretty 'c' <> "d") -- >>> hsep (replicate 5 oftenUsed)@@ -1844,7 +1850,7 @@ -- >>> let doc = (fun . fun . fun . fun . fun) (align (list ["abcdef", "ghijklm"])) -- -- which we’ll be rendering using the following pipeline (where the layout--- algorithm has been left open),+-- algorithm has been left open): -- -- >>> import Data.Text.IO as T -- >>> import Prettyprinter.Render.Text@@ -1853,7 +1859,7 @@ -- -- If we render this using 'layoutPretty' with a page width of 26 characters -- per line, all the @fun@ calls fit into the first line so they will be put--- there,+-- there: -- -- >>> go layoutPretty doc -- |------------------------|
src/Prettyprinter/Render/Text.hs view
@@ -1,12 +1,13 @@ {-# LANGUAGE CPP #-}-{-# LANGUAGE OverloadedStrings #-} #include "version-compatibility-macros.h" -- | Render an unannotated 'SimpleDocStream' as plain 'Text'. module Prettyprinter.Render.Text (+#ifdef MIN_VERSION_text -- * Conversion to plain 'Text' renderLazy, renderStrict,+#endif -- * Render to a 'Handle' renderIO,
src/Prettyprinter/Render/Util/SimpleDocTree.hs view
@@ -1,7 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE OverloadedStrings #-} #include "version-compatibility-macros.h"
test/Testsuite/Main.hs view
@@ -15,10 +15,10 @@ import Data.Word import System.Timeout (timeout) -import Data.Text.Prettyprint.Doc-import Data.Text.Prettyprint.Doc.Internal.Debug-import Data.Text.Prettyprint.Doc.Render.Text-import Data.Text.Prettyprint.Doc.Render.Util.StackMachine (renderSimplyDecorated)+import Prettyprinter+import Prettyprinter.Internal.Debug+import Prettyprinter.Render.Text+import Prettyprinter.Render.Util.StackMachine (renderSimplyDecorated) import Test.QuickCheck.Instances.Text () import Test.Tasty
test/Testsuite/StripTrailingSpace.hs view
@@ -10,8 +10,8 @@ import Data.Text (Text) import qualified Data.Text as T -import Data.Text.Prettyprint.Doc-import Data.Text.Prettyprint.Doc.Render.Util.StackMachine+import Prettyprinter+import Prettyprinter.Render.Util.StackMachine import Test.Tasty import Test.Tasty.HUnit