packages feed

prettyprinter-ansi-terminal 1.1.3 → 1.1.4

raw patch · 9 files changed

+142/−48 lines, 9 filesdep +tasty-benchdep −gaugedep −semigroupsdep ~QuickCheckdep ~basedep ~base-compat

Dependencies added: tasty-bench

Dependencies removed: gauge, semigroups

Dependency ranges changed: QuickCheck, base, base-compat

Files

CHANGELOG.md view
@@ -1,3 +1,13 @@+# [1.1.4] – April 2026++- [Add `text` flag](https://github.com/quchen/prettyprinter/pull/279)+- [Fix inconsistency between `renderLazy`/`renderIO`](https://github.com/quchen/prettyprinter/pull/261)+- [Drop support for GHC 7](https://github.com/quchen/prettyprinter/pull/278)+- [Remove compatibility code for GHC < 8](https://github.com/quchen/prettyprinter/pull/285)+- [Make it compile with MicroHs](https://github.com/quchen/prettyprinter/pull/270)++[1.1.4]: https://github.com/quchen/prettyprinter/compare/ansi-terminal-v1.1.3...ansi-terminal-v1.1.4+ # [1.1.3]  - [Deprecate the `Data.Text.Prettyprint.*` modules](https://github.com/quchen/prettyprinter/pull/203)
bench/LargeOutput.hs view
@@ -1,5 +1,4 @@ {-# LANGUAGE DeriveGeneric     #-}-{-# LANGUAGE LambdaCase        #-} {-# LANGUAGE OverloadedStrings #-}  {-# OPTIONS_GHC -fno-warn-orphans #-}@@ -19,7 +18,6 @@ import qualified Data.Text                             as T import qualified Data.Text.IO                          as T import qualified Data.Text.Lazy                        as TL-import           Gauge import           GHC.Generics import           Prettyprinter import           Prettyprinter.Render.Terminal         as Terminal@@ -27,6 +25,7 @@ import           Test.QuickCheck import           Test.QuickCheck.Gen import           Test.QuickCheck.Random+import           Test.Tasty.Bench   @@ -85,7 +84,7 @@ anCol = annotate . color  prettyProgram :: Program -> Doc AnsiStyle-prettyProgram (Program binds) = annotate italicized $ prettyBinds binds+prettyProgram (Program binds) = annotate italicized (prettyBinds binds)  prettyBinds :: Binds -> Doc AnsiStyle prettyBinds (Binds bs) = align (vsep (map prettyBinding (M.assocs bs)))@@ -93,7 +92,7 @@     prettyBinding (var, lambda) = pretty var <+> anCol Red "=" <+> prettyLambdaForm lambda  prettyLambdaForm :: LambdaForm -> Doc AnsiStyle-prettyLambdaForm (LambdaForm free bound body) = prettyExp . (<+> anCol Blue "->") . prettyBound . prettyFree $ anCol Blue "\\"+prettyLambdaForm (LambdaForm free bound body) = (prettyExp . (<+> anCol Blue "->") . prettyBound . prettyFree) (anCol Blue "\\")   where     prettyFree | null free = id                | otherwise = (<> anCol Blue lparen <> hsep (map pretty free) <> anCol Blue rparen)@@ -103,7 +102,7 @@     prettyExp = (<+> prettyExpr body)  prettyExpr :: Expr -> Doc AnsiStyle-prettyExpr = \case+prettyExpr = \expr -> case expr of     Let binds body ->         align (vsep [ anCol Red "let" <+> align (prettyBinds binds)                     , anCol Red "in" <+> prettyExpr body ])@@ -112,15 +111,15 @@         [ anCol Yellow "case" <+> prettyExpr scrutinee <+> anCol Yellow "of"         , indent 4 (align (vsep (map prettyAlt alts))) ] -    AppF f [] -> annotate bold . anCol Green $ pretty f-    AppF f args -> annotate bold . anCol Green $ pretty f <+> hsep (map pretty args)+    AppF f [] -> (annotate bold . anCol Green) (pretty f)+    AppF f args -> (annotate bold . anCol Green) (pretty f) <+> hsep (map pretty args) -    AppC c [] -> annotate bold . anCol Green $ pretty c-    AppC c args -> annotate bold . anCol Green $ pretty c <+> hsep (map pretty args)+    AppC c [] -> (annotate bold . anCol Green) (pretty c)+    AppC c args -> (annotate bold . anCol Green) (pretty c) <+> hsep (map pretty args) -    AppP op x y -> annotate bold . anCol Green $ pretty op <+> pretty x <+> pretty y+    AppP op x y -> (annotate bold . anCol Green) (pretty op) <+> pretty x <+> pretty y -    LitE lit -> annotate bold . anCol Green $ pretty lit+    LitE lit -> (annotate bold . anCol Green) (pretty lit)  prettyAlt :: Alt -> Doc AnsiStyle prettyAlt (Alt con [] body) = pretty con <+> anCol Yellow "->" <+> prettyExpr body@@ -154,6 +153,6 @@     rnf prog `seq` T.putStrLn "Starting benchmark…"      defaultMain-        [ bench "prettyprinter-ansi-terminal" $ nf (render Terminal.renderLazy) prog-        , bench "prettyprinter" $ nf (render Text.renderLazy) prog+        [ bench "prettyprinter-ansi-terminal" (nf (render Terminal.renderLazy) prog)+        , bench "prettyprinter" (nf (render Text.renderLazy) prog)         ]
misc/version-compatibility-macros.h view
@@ -8,13 +8,9 @@ -- These macros allow writing CPP compatibility hacks in a way that makes their -- purpose much clearer than just demanding a specific version of a library. -#define APPLICATIVE_MONAD               MIN_VERSION_base(4,8,0)-#define FOLDABLE_TRAVERSABLE_IN_PRELUDE MIN_VERSION_base(4,8,0)-#define FUNCTOR_IDENTITY_IN_BASE        MIN_VERSION_base(4,8,0)-#define MONOID_IN_PRELUDE               MIN_VERSION_base(4,8,0)-#define NATURAL_IN_BASE                 MIN_VERSION_base(4,8,0)+#define FOLDABLE_TRAVERSABLE_IN_PRELUDE !defined(__MHS__) -#define SEMIGROUP_IN_BASE               MIN_VERSION_base(4,9,0)+#define LIFTA2_IN_PRELUDE               MIN_VERSION_base(4,18,0)  #define SEMIGROUP_MONOID_SUPERCLASS     MIN_VERSION_base(4,11,0) 
prettyprinter-ansi-terminal.cabal view
@@ -1,5 +1,5 @@ name:                prettyprinter-ansi-terminal-version:             1.1.3+version:             1.1.4 cabal-version:       >= 1.10 category:            User Interfaces, Text synopsis:            ANSI terminal backend for the »prettyprinter« package.@@ -14,18 +14,27 @@ 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+tested-with:         GHC==9.14.1, GHC==9.12.2, GHC==9.10.3, GHC==9.8.4, GHC==9.6.7, GHC==9.4.8, GHC==9.2.8, GHC==9.0.2, GHC==8.10.7, GHC==8.8.4, GHC==8.6.5, GHC==8.4.4, GHC==8.2.2, GHC==8.0.2  source-repository head   type: git-  location: git://github.com/quchen/prettyprinter.git+  location: https://github.com/quchen/prettyprinter +flag text+  description: While it's a core value of @prettyprinter@ packages 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-ansi-terminal@ fallbacks to @String@.+  default:     True+  manual:      True+ library     exposed-modules:  Data.Text.Prettyprint.Doc.Render.Terminal                     , Data.Text.Prettyprint.Doc.Render.Terminal.Internal                     , Prettyprinter.Render.Terminal                     , Prettyprinter.Render.Terminal.Internal-    ghc-options:      -Wall -O2+    ghc-options:      -Wall -O2 -Wcompat     hs-source-dirs:   src     include-dirs:     misc     default-language: Haskell2010@@ -35,39 +44,40 @@       build-depends:-          base          >= 4.5 && < 5+          base          >= 4.9 && < 5         , ansi-terminal >= 0.4.0-        , text          >= 1.2         , prettyprinter >= 1.7.0--    if impl(ghc >= 8.0)-        ghc-options: -Wcompat-    if !impl(ghc >= 8.0)-        build-depends: semigroups >= 0.1+    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  test-suite doctest     type: exitcode-stdio-1.0     hs-source-dirs: test/Doctest     main-is: Main.hs     build-depends:-          base    >= 4.7 && < 5+          base    >= 4.9 && < 5         , doctest >= 0.9     ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N     default-language: Haskell2010-    if impl (ghc < 7.10)-        buildable: False-        -- Doctest cannot search folders in old versions it seems :-(  benchmark large-output     build-depends:-          base >= 4.5 && < 5-        , base-compat >=0.9.3 && <0.12+          base >= 4.9 && < 5+        , base-compat >=0.9.3 && <0.15         , containers         , deepseq-        , gauge >= 0.2+        , tasty-bench >= 0.2         , prettyprinter         , prettyprinter-ansi-terminal-        , QuickCheck >= 2.7+        , QuickCheck >= 2.8         , text      hs-source-dirs:      bench
+ 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/Prettyprinter/Render/Terminal/Internal.hs view
@@ -53,15 +53,7 @@ import Prettyprinter.Render.Util.Panic  #if !(SEMIGROUP_MONOID_SUPERCLASS)-import Data.Semigroup-#endif--#if !(MIN_VERSION_base(4,6,0))-modifyIORef' :: IORef a -> (a -> a) -> IO ()-modifyIORef' ref f = do-    x <- readIORef ref-    let x' = f x-    x' `seq` writeIORef ref x'+import Data.Semigroup (Semigroup(..)) #endif  -- $setup@@ -160,7 +152,7 @@             SAnnPush style rest ->                 let currentStyle = unsafePeek s                     newStyle = style <> currentStyle-                in  TLB.fromText (styleToRawText newStyle) <> go (push style s) rest+                in  TLB.fromText (styleToRawText newStyle) <> go (push newStyle s) rest             SAnnPop rest ->                 let (_currentStyle, s') = unsafePop s                     newStyle = unsafePeek s'