packages feed

text-ansi 0.1.0.2 → 0.1.1

raw patch · 4 files changed

+489/−138 lines, 4 filesdep ~basedep ~textPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, text

API changes (from Hackage documentation)

+ Data.Text.Builder.ANSI: black :: Builder -> Builder
+ Data.Text.Builder.ANSI: blackBg :: Builder -> Builder
+ Data.Text.Builder.ANSI: blue :: Builder -> Builder
+ Data.Text.Builder.ANSI: blueBg :: Builder -> Builder
+ Data.Text.Builder.ANSI: bold :: Builder -> Builder
+ Data.Text.Builder.ANSI: brightBlack :: Builder -> Builder
+ Data.Text.Builder.ANSI: brightBlackBg :: Builder -> Builder
+ Data.Text.Builder.ANSI: brightBlue :: Builder -> Builder
+ Data.Text.Builder.ANSI: brightBlueBg :: Builder -> Builder
+ Data.Text.Builder.ANSI: brightCyan :: Builder -> Builder
+ Data.Text.Builder.ANSI: brightCyanBg :: Builder -> Builder
+ Data.Text.Builder.ANSI: brightGreen :: Builder -> Builder
+ Data.Text.Builder.ANSI: brightGreenBg :: Builder -> Builder
+ Data.Text.Builder.ANSI: brightMagenta :: Builder -> Builder
+ Data.Text.Builder.ANSI: brightMagentaBg :: Builder -> Builder
+ Data.Text.Builder.ANSI: brightRed :: Builder -> Builder
+ Data.Text.Builder.ANSI: brightRedBg :: Builder -> Builder
+ Data.Text.Builder.ANSI: brightWhite :: Builder -> Builder
+ Data.Text.Builder.ANSI: brightWhiteBg :: Builder -> Builder
+ Data.Text.Builder.ANSI: brightYellow :: Builder -> Builder
+ Data.Text.Builder.ANSI: brightYellowBg :: Builder -> Builder
+ Data.Text.Builder.ANSI: cyan :: Builder -> Builder
+ Data.Text.Builder.ANSI: cyanBg :: Builder -> Builder
+ Data.Text.Builder.ANSI: doubleUnderline :: Builder -> Builder
+ Data.Text.Builder.ANSI: encircle :: Builder -> Builder
+ Data.Text.Builder.ANSI: faint :: Builder -> Builder
+ Data.Text.Builder.ANSI: frame :: Builder -> Builder
+ Data.Text.Builder.ANSI: green :: Builder -> Builder
+ Data.Text.Builder.ANSI: greenBg :: Builder -> Builder
+ Data.Text.Builder.ANSI: italic :: Builder -> Builder
+ Data.Text.Builder.ANSI: magenta :: Builder -> Builder
+ Data.Text.Builder.ANSI: magentaBg :: Builder -> Builder
+ Data.Text.Builder.ANSI: overline :: Builder -> Builder
+ Data.Text.Builder.ANSI: red :: Builder -> Builder
+ Data.Text.Builder.ANSI: redBg :: Builder -> Builder
+ Data.Text.Builder.ANSI: rgb :: Word8 -> Word8 -> Word8 -> Builder -> Builder
+ Data.Text.Builder.ANSI: rgbBg :: Word8 -> Word8 -> Word8 -> Builder -> Builder
+ Data.Text.Builder.ANSI: strikethrough :: Builder -> Builder
+ Data.Text.Builder.ANSI: underline :: Builder -> Builder
+ Data.Text.Builder.ANSI: white :: Builder -> Builder
+ Data.Text.Builder.ANSI: whiteBg :: Builder -> Builder
+ Data.Text.Builder.ANSI: yellow :: Builder -> Builder
+ Data.Text.Builder.ANSI: yellowBg :: Builder -> Builder

Files

CHANGELOG.md view
@@ -5,7 +5,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to the [Haskell Package Versioning Policy](https://pvp.haskell.org/). +## [0.1.1] - 2021-01-07++## Added+- Add `Data.Text.Builder.ANSI` module+ ## [0.1.0.2] - 2020-12-26+ ### Changed - Fix bug in `italic` 
Data/Text/ANSI.hs view
@@ -1,6 +1,3 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE OverloadedStrings #-}- module Data.Text.ANSI   ( -- $intro @@ -55,17 +52,12 @@   ) where -#if !MIN_VERSION_base(4,13,0)-import Data.Semigroup ((<>))-#endif-import Data.Text+import Data.Text (Text)+import qualified Data.Text.Builder.ANSI as Builder.ANSI import qualified Data.Text.Lazy as Text.Lazy import Data.Text.Lazy.Builder (Builder) import qualified Data.Text.Lazy.Builder as Builder-import qualified Data.Text.Lazy.Builder.Int as Builder import Data.Word (Word8)-import Foreign.C (CInt (CInt))-import System.IO.Unsafe (unsafePerformIO)  -- $intro --@@ -83,303 +75,272 @@ -- | Black foreground. black :: Text -> Text black =-  foreground "30"-{-# INLINEABLE black #-}+  lift Builder.ANSI.black+{-# INLINE black #-}  -- | Red foreground. red :: Text -> Text red =-  foreground "31"-{-# INLINEABLE red #-}+  lift Builder.ANSI.red+{-# INLINE red #-}  -- | Green foreground. green :: Text -> Text green =-  foreground "32"-{-# INLINEABLE green #-}+  lift Builder.ANSI.green+{-# INLINE green #-}  -- | Yellow foreground. yellow :: Text -> Text yellow =-  foreground "33"-{-# INLINEABLE yellow #-}+  lift Builder.ANSI.yellow+{-# INLINE yellow #-}  -- | Blue foreground. blue :: Text -> Text blue =-  foreground "34"-{-# INLINEABLE blue #-}+  lift Builder.ANSI.blue+{-# INLINE blue #-}  -- | Magenta foreground. magenta :: Text -> Text magenta =-  foreground "35"-{-# INLINEABLE magenta #-}+  lift Builder.ANSI.magenta+{-# INLINE magenta #-}  -- | Cyan foreground. cyan :: Text -> Text cyan =-  foreground "36"-{-# INLINEABLE cyan #-}+  lift Builder.ANSI.cyan+{-# INLINE cyan #-}  -- | White foreground. white :: Text -> Text white =-  foreground "37"-{-# INLINEABLE white #-}+  lift Builder.ANSI.white+{-# INLINE white #-}  -- | Bright black foreground. brightBlack :: Text -> Text brightBlack =-  foreground "90"-{-# INLINEABLE brightBlack #-}+  lift Builder.ANSI.brightBlack+{-# INLINE brightBlack #-}  -- | Bright red foreground. brightRed :: Text -> Text brightRed =-  foreground "91"-{-# INLINEABLE brightRed #-}+  lift Builder.ANSI.brightRed+{-# INLINE brightRed #-}  -- | Bright green foreground. brightGreen :: Text -> Text brightGreen =-  foreground "92"-{-# INLINEABLE brightGreen #-}+  lift Builder.ANSI.brightGreen+{-# INLINE brightGreen #-}  -- | Bright yellow foreground. brightYellow :: Text -> Text brightYellow =-  foreground "93"-{-# INLINEABLE brightYellow #-}+  lift Builder.ANSI.brightYellow+{-# INLINE brightYellow #-}  -- | Bright blue foreground. brightBlue :: Text -> Text brightBlue =-  foreground "94"-{-# INLINEABLE brightBlue #-}+  lift Builder.ANSI.brightBlue+{-# INLINE brightBlue #-}  -- | Bright magenta foreground. brightMagenta :: Text -> Text brightMagenta =-  foreground "95"-{-# INLINEABLE brightMagenta #-}+  lift Builder.ANSI.brightMagenta+{-# INLINE brightMagenta #-}  -- | Bright cyan foreground. brightCyan :: Text -> Text brightCyan =-  foreground "96"-{-# INLINEABLE brightCyan #-}+  lift Builder.ANSI.brightCyan+{-# INLINE brightCyan #-}  -- | Bright white foreground. brightWhite :: Text -> Text brightWhite =-  foreground "97"-{-# INLINEABLE brightWhite #-}+  lift Builder.ANSI.brightWhite+{-# INLINE brightWhite #-}  -- | RGB foreground. rgb :: Word8 -> Word8 -> Word8 -> Text -> Text rgb r g b =-  foreground ("38;2;" <> Builder.decimal r <> semi <> Builder.decimal g <> semi <> Builder.decimal b)-{-# INLINEABLE rgb #-}--foreground :: Builder -> Text -> Text-foreground s =-  surround s "39"-{-# INLINE foreground #-}+  lift (Builder.ANSI.rgb r g b)+{-# INLINE rgb #-}  -- | Black background. blackBg :: Text -> Text blackBg =-  background "40"-{-# INLINEABLE blackBg #-}+  lift Builder.ANSI.blackBg+{-# INLINE blackBg #-}  -- | Red background. redBg :: Text -> Text redBg =-  background "41"-{-# INLINEABLE redBg #-}+  lift Builder.ANSI.redBg+{-# INLINE redBg #-}  -- | Green background. greenBg :: Text -> Text greenBg =-  background "42"-{-# INLINEABLE greenBg #-}+  lift Builder.ANSI.greenBg+{-# INLINE greenBg #-}  -- | Yellow background. yellowBg :: Text -> Text yellowBg =-  background "43"-{-# INLINEABLE yellowBg #-}+  lift Builder.ANSI.yellowBg+{-# INLINE yellowBg #-}  -- | Blue background. blueBg :: Text -> Text blueBg =-  background "44"-{-# INLINEABLE blueBg #-}+  lift Builder.ANSI.blueBg+{-# INLINE blueBg #-}  -- | Magenta background. magentaBg :: Text -> Text magentaBg =-  background "45"-{-# INLINEABLE magentaBg #-}+  lift Builder.ANSI.magentaBg+{-# INLINE magentaBg #-}  -- | Cyan background. cyanBg :: Text -> Text cyanBg =-  background "46"-{-# INLINEABLE cyanBg #-}+  lift Builder.ANSI.cyanBg+{-# INLINE cyanBg #-}  -- | White background. whiteBg :: Text -> Text whiteBg =-  background "47"-{-# INLINEABLE whiteBg #-}+  lift Builder.ANSI.whiteBg+{-# INLINE whiteBg #-}  -- | Bright black background. brightBlackBg :: Text -> Text brightBlackBg =-  background "100"-{-# INLINEABLE brightBlackBg #-}+  lift Builder.ANSI.brightBlackBg+{-# INLINE brightBlackBg #-}  -- | Bright red background. brightRedBg :: Text -> Text brightRedBg =-  background "101"-{-# INLINEABLE brightRedBg #-}+  lift Builder.ANSI.brightRedBg+{-# INLINE brightRedBg #-}  -- | Bright green background. brightGreenBg :: Text -> Text brightGreenBg =-  background "102"-{-# INLINEABLE brightGreenBg #-}+  lift Builder.ANSI.brightGreenBg+{-# INLINE brightGreenBg #-}  -- | Bright yellow background. brightYellowBg :: Text -> Text brightYellowBg =-  background "103"-{-# INLINEABLE brightYellowBg #-}+  lift Builder.ANSI.brightYellowBg+{-# INLINE brightYellowBg #-}  -- | Bright blue background. brightBlueBg :: Text -> Text brightBlueBg =-  background "104"-{-# INLINEABLE brightBlueBg #-}+  lift Builder.ANSI.brightBlueBg+{-# INLINE brightBlueBg #-}  -- | Bright magenta background. brightMagentaBg :: Text -> Text brightMagentaBg =-  background "105"-{-# INLINEABLE brightMagentaBg #-}+  lift Builder.ANSI.brightMagentaBg+{-# INLINE brightMagentaBg #-}  -- | Bright cyan background. brightCyanBg :: Text -> Text brightCyanBg =-  background "106"-{-# INLINEABLE brightCyanBg #-}+  lift Builder.ANSI.brightCyanBg+{-# INLINE brightCyanBg #-}  -- | Bright white background. brightWhiteBg :: Text -> Text brightWhiteBg =-  background "107"-{-# INLINEABLE brightWhiteBg #-}--background :: Builder -> Text -> Text-background s =-  surround s "49"-{-# INLINE background #-}+  lift Builder.ANSI.brightWhiteBg+{-# INLINE brightWhiteBg #-}  -- | RGB background. rgbBg :: Word8 -> Word8 -> Word8 -> Text -> Text rgbBg r g b =-  background ("48;2;" <> Builder.decimal r <> semi <> Builder.decimal g <> semi <> Builder.decimal b)-{-# INLINEABLE rgbBg #-}+  lift (Builder.ANSI.rgbBg r g b)+{-# INLINE rgbBg #-}  -- | __Bold__ style (high intensity). bold :: Text -> Text bold =-  surround "1" "22"-{-# INLINEABLE bold #-}+  lift Builder.ANSI.bold+{-# INLINE bold #-}  -- | Faint style (low intensity). faint :: Text -> Text faint =-  surround "2" "22"-{-# INLINEABLE faint #-}+  lift Builder.ANSI.faint+{-# INLINE faint #-}  -- | /Italic/ style. italic :: Text -> Text italic =-  surround "3" "23"-{-# INLINEABLE italic #-}+  lift Builder.ANSI.italic+{-# INLINE italic #-}  -- | U̲n̲d̲e̲r̲l̲i̲n̲e̲ style. underline :: Text -> Text underline =-  surround "4" "24"-{-# INLINEABLE underline #-}+  lift Builder.ANSI.underline+{-# INLINE underline #-}  -- | D̳o̳u̳b̳l̳e̳ ̳u̳n̳d̳e̳r̳l̳i̳n̳e̳ style. doubleUnderline :: Text -> Text doubleUnderline =-  surround "21" "24"-{-# INLINEABLE doubleUnderline #-}+  lift Builder.ANSI.doubleUnderline+{-# INLINE doubleUnderline #-}  -- | S̶t̶r̶i̶k̶e̶t̶h̶r̶o̶u̶g̶h̶ style. strikethrough :: Text -> Text strikethrough =-  surround "9" "29"-{-# INLINEABLE strikethrough #-}+  lift Builder.ANSI.strikethrough+{-# INLINE strikethrough #-}  -- | Frame style. frame :: Text -> Text frame =-  surround "51" "54"-{-# INLINEABLE frame #-}+  lift Builder.ANSI.frame+{-# INLINE frame #-}  -- | Encircle style. encircle :: Text -> Text encircle =-  surround "52" "54"-{-# INLINEABLE encircle #-}+  lift Builder.ANSI.encircle+{-# INLINE encircle #-}  -- | O̅v̅e̅r̅l̅i̅n̅e̅ style. overline :: Text -> Text overline =-  surround "53" "55"-{-# INLINEABLE overline #-}------------------------------------------------------------------------------------surround :: Builder -> Builder -> Text -> Text-surround open close text-  | isatty = Text.Lazy.toStrict (Builder.toLazyText (esc <> open <> m <> Builder.fromText text <> esc <> close <> m))-  | otherwise = text--- Don't inline before phase 1-{-# NOINLINE [1] surround #-}--esc :: Builder-esc =-  "\ESC["--m :: Builder-m =-  Builder.singleton 'm'--semi :: Builder-semi =-  Builder.singleton ';'+  lift Builder.ANSI.overline+{-# INLINE overline #-} -isatty :: Bool-isatty =-  unsafePerformIO (c_isatty 1) == 1-{-# NOINLINE isatty #-}+-- -foreign import ccall unsafe "isatty"-  c_isatty :: CInt -> IO CInt+lift :: (Builder -> Builder) -> Text -> Text+lift f =+  Text.Lazy.toStrict . Builder.toLazyText . f . Builder.fromText+-- Don't inline before phase 2+{-# NOINLINE [2] lift #-} --- Collapse surround/surround to a single surround before phase 1+-- Collapse lift/lift to a single lift before phase 2 {-# RULES-"surround/surround" [~1] forall a b c d s.-  surround a b (surround c d s) =-    surround (a <> semi <> c) (b <> semi <> d) s+"lift/lift" [~2] forall f g s.+  lift f (lift g s) =+    lift (f . g) s   #-}
+ Data/Text/Builder/ANSI.hs view
@@ -0,0 +1,383 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}++module Data.Text.Builder.ANSI+  ( -- $intro++    -- * Foreground color+    black,+    red,+    green,+    yellow,+    blue,+    magenta,+    cyan,+    white,+    brightBlack,+    brightRed,+    brightGreen,+    brightYellow,+    brightBlue,+    brightMagenta,+    brightCyan,+    brightWhite,+    rgb,++    -- * Background color+    blackBg,+    redBg,+    greenBg,+    yellowBg,+    blueBg,+    magentaBg,+    cyanBg,+    whiteBg,+    brightBlackBg,+    brightRedBg,+    brightGreenBg,+    brightYellowBg,+    brightBlueBg,+    brightMagentaBg,+    brightCyanBg,+    brightWhiteBg,+    rgbBg,++    -- * Style+    bold,+    faint,+    italic,+    underline,+    doubleUnderline,+    strikethrough,+    frame,+    encircle,+    overline,+  )+where++#if !MIN_VERSION_base(4,13,0)+import Data.Semigroup ((<>))+#endif+import Data.Text.Lazy.Builder (Builder)+import qualified Data.Text.Lazy.Builder as Builder+import qualified Data.Text.Lazy.Builder.Int as Builder+import Data.Word (Word8)+import Foreign.C (CInt (CInt))+import System.IO.Unsafe (unsafePerformIO)++-- $intro+--+-- Text styling for ANSI terminals using SGR codes, as defined by the+-- <https://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf ECMA-48>+-- standard.+--+-- Supports foreground\/background color, bold\/faint intensity, italic,+-- single\/double underline, strikethrough, frame, encircle, and overline escape+-- sequences. Some styles may not work on your terminal.+--+-- Also features terminal detection, so redirecting styled output to a file will+-- automatically strip the ANSI escape sequences.++-- | Black foreground.+black :: Builder -> Builder+black =+  foreground "30"+{-# INLINE black #-}++-- | Red foreground.+red :: Builder -> Builder+red =+  foreground "31"+{-# INLINE red #-}++-- | Green foreground.+green :: Builder -> Builder+green =+  foreground "32"+{-# INLINE green #-}++-- | Yellow foreground.+yellow :: Builder -> Builder+yellow =+  foreground "33"+{-# INLINE yellow #-}++-- | Blue foreground.+blue :: Builder -> Builder+blue =+  foreground "34"+{-# INLINE blue #-}++-- | Magenta foreground.+magenta :: Builder -> Builder+magenta =+  foreground "35"+{-# INLINE magenta #-}++-- | Cyan foreground.+cyan :: Builder -> Builder+cyan =+  foreground "36"+{-# INLINE cyan #-}++-- | White foreground.+white :: Builder -> Builder+white =+  foreground "37"+{-# INLINE white #-}++-- | Bright black foreground.+brightBlack :: Builder -> Builder+brightBlack =+  foreground "90"+{-# INLINE brightBlack #-}++-- | Bright red foreground.+brightRed :: Builder -> Builder+brightRed =+  foreground "91"+{-# INLINE brightRed #-}++-- | Bright green foreground.+brightGreen :: Builder -> Builder+brightGreen =+  foreground "92"+{-# INLINE brightGreen #-}++-- | Bright yellow foreground.+brightYellow :: Builder -> Builder+brightYellow =+  foreground "93"+{-# INLINE brightYellow #-}++-- | Bright blue foreground.+brightBlue :: Builder -> Builder+brightBlue =+  foreground "94"+{-# INLINE brightBlue #-}++-- | Bright magenta foreground.+brightMagenta :: Builder -> Builder+brightMagenta =+  foreground "95"+{-# INLINE brightMagenta #-}++-- | Bright cyan foreground.+brightCyan :: Builder -> Builder+brightCyan =+  foreground "96"+{-# INLINE brightCyan #-}++-- | Bright white foreground.+brightWhite :: Builder -> Builder+brightWhite =+  foreground "97"+{-# INLINE brightWhite #-}++-- | RGB foreground.+rgb :: Word8 -> Word8 -> Word8 -> Builder -> Builder+rgb r g b =+  foreground ("38;2;" <> Builder.decimal r <> semi <> Builder.decimal g <> semi <> Builder.decimal b)+{-# INLINE rgb #-}++foreground :: Builder -> Builder -> Builder+foreground s =+  surround s "39"+{-# INLINE foreground #-}++-- | Black background.+blackBg :: Builder -> Builder+blackBg =+  background "40"+{-# INLINE blackBg #-}++-- | Red background.+redBg :: Builder -> Builder+redBg =+  background "41"+{-# INLINE redBg #-}++-- | Green background.+greenBg :: Builder -> Builder+greenBg =+  background "42"+{-# INLINE greenBg #-}++-- | Yellow background.+yellowBg :: Builder -> Builder+yellowBg =+  background "43"+{-# INLINE yellowBg #-}++-- | Blue background.+blueBg :: Builder -> Builder+blueBg =+  background "44"+{-# INLINE blueBg #-}++-- | Magenta background.+magentaBg :: Builder -> Builder+magentaBg =+  background "45"+{-# INLINE magentaBg #-}++-- | Cyan background.+cyanBg :: Builder -> Builder+cyanBg =+  background "46"+{-# INLINE cyanBg #-}++-- | White background.+whiteBg :: Builder -> Builder+whiteBg =+  background "47"+{-# INLINE whiteBg #-}++-- | Bright black background.+brightBlackBg :: Builder -> Builder+brightBlackBg =+  background "100"+{-# INLINE brightBlackBg #-}++-- | Bright red background.+brightRedBg :: Builder -> Builder+brightRedBg =+  background "101"+{-# INLINE brightRedBg #-}++-- | Bright green background.+brightGreenBg :: Builder -> Builder+brightGreenBg =+  background "102"+{-# INLINE brightGreenBg #-}++-- | Bright yellow background.+brightYellowBg :: Builder -> Builder+brightYellowBg =+  background "103"+{-# INLINE brightYellowBg #-}++-- | Bright blue background.+brightBlueBg :: Builder -> Builder+brightBlueBg =+  background "104"+{-# INLINE brightBlueBg #-}++-- | Bright magenta background.+brightMagentaBg :: Builder -> Builder+brightMagentaBg =+  background "105"+{-# INLINE brightMagentaBg #-}++-- | Bright cyan background.+brightCyanBg :: Builder -> Builder+brightCyanBg =+  background "106"+{-# INLINE brightCyanBg #-}++-- | Bright white background.+brightWhiteBg :: Builder -> Builder+brightWhiteBg =+  background "107"+{-# INLINE brightWhiteBg #-}++background :: Builder -> Builder -> Builder+background s =+  surround s "49"+{-# INLINE background #-}++-- | RGB background.+rgbBg :: Word8 -> Word8 -> Word8 -> Builder -> Builder+rgbBg r g b =+  background ("48;2;" <> Builder.decimal r <> semi <> Builder.decimal g <> semi <> Builder.decimal b)+{-# INLINE rgbBg #-}++-- | __Bold__ style (high intensity).+bold :: Builder -> Builder+bold =+  surround "1" "22"+{-# INLINE bold #-}++-- | Faint style (low intensity).+faint :: Builder -> Builder+faint =+  surround "2" "22"+{-# INLINE faint #-}++-- | /Italic/ style.+italic :: Builder -> Builder+italic =+  surround "3" "23"+{-# INLINE italic #-}++-- | U̲n̲d̲e̲r̲l̲i̲n̲e̲ style.+underline :: Builder -> Builder+underline =+  surround "4" "24"+{-# INLINE underline #-}++-- | D̳o̳u̳b̳l̳e̳ ̳u̳n̳d̳e̳r̳l̳i̳n̳e̳ style.+doubleUnderline :: Builder -> Builder+doubleUnderline =+  surround "21" "24"+{-# INLINE doubleUnderline #-}++-- | S̶t̶r̶i̶k̶e̶t̶h̶r̶o̶u̶g̶h̶ style.+strikethrough :: Builder -> Builder+strikethrough =+  surround "9" "29"+{-# INLINE strikethrough #-}++-- | Frame style.+frame :: Builder -> Builder+frame =+  surround "51" "54"+{-# INLINE frame #-}++-- | Encircle style.+encircle :: Builder -> Builder+encircle =+  surround "52" "54"+{-# INLINE encircle #-}++-- | O̅v̅e̅r̅l̅i̅n̅e̅ style.+overline :: Builder -> Builder+overline =+  surround "53" "55"+{-# INLINE overline #-}++--------------------------------------------------------------------------------++surround :: Builder -> Builder -> Builder -> Builder+surround open close text+  | isatty = esc <> open <> m <> text <> esc <> close <> m+  | otherwise = text+-- Don't inline before phase 1+{-# NOINLINE [1] surround #-}++esc :: Builder+esc =+  "\ESC["++m :: Builder+m =+  Builder.singleton 'm'++semi :: Builder+semi =+  Builder.singleton ';'++isatty :: Bool+isatty =+  unsafePerformIO (c_isatty 1) == 1+{-# NOINLINE isatty #-}++foreign import ccall unsafe "isatty"+  c_isatty :: CInt -> IO CInt++-- Collapse surround/surround to a single surround before phase 1+{-# RULES+"surround/surround" [~1] forall a b c d s.+  surround a b (surround c d s) =+    surround (a <> semi <> c) (b <> semi <> d) s+  #-}
text-ansi.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2  name: text-ansi-version: 0.1.0.2+version: 0.1.1 category: Data synopsis: Text styling for ANSI terminals. description:@@ -41,6 +41,7 @@     Haskell2010   exposed-modules:     Data.Text.ANSI+    Data.Text.Builder.ANSI   ghc-options:     -Weverything     -Wno-implicit-prelude