File tree Expand file tree Collapse file tree 9 files changed +75
-12
lines changed
Expand file tree Collapse file tree 9 files changed +75
-12
lines changed Original file line number Diff line number Diff line change 1- {-# LANGUAGE DeriveGeneric #-}
2- {-# LANGUAGE OverloadedStrings #-}
1+ {-# LANGUAGE DeriveGeneric #-}
2+ {-# LANGUAGE FlexibleInstances #-}
3+ {-# LANGUAGE OverloadedStrings #-}
4+ {-# LANGUAGE TypeSynonymInstances #-}
35
46{-# OPTIONS_GHC -fno-warn-orphans #-}
57
@@ -13,10 +15,10 @@ import Control.Monad.Compat
1315import Data.Char
1416import Data.Map (Map )
1517import qualified Data.Map as M
16- import Data. Text (Text )
17- import qualified Data. Text as T
18- import qualified Data. Text.IO as T
19- import qualified Data. Text.Lazy as TL
18+ import Prettyprinter.Util.Compat. Text (Text )
19+ import qualified Prettyprinter.Util.Compat. Text as T
20+ import qualified Prettyprinter.Util.Compat. Text.IO as T
21+ import qualified Prettyprinter.Util.Compat. Text.Lazy as TL
2022import Prettyprinter
2123import Prettyprinter.Render.Text
2224import GHC.Generics
Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ library
3636 , Prettyprinter.Render.Util.SimpleDocTree
3737 , Prettyprinter.Render.Util.StackMachine
3838 , Prettyprinter.Util
39+ , Prettyprinter.Util.Compat.Text
40+ , Prettyprinter.Util.Compat.Text.IO
41+ , Prettyprinter.Util.Compat.Text.Lazy
42+ , Prettyprinter.Util.Compat.Text.Lazy.Builder
3943
4044 , Prettyprinter.Symbols.Unicode
4145 , Prettyprinter.Symbols.Ascii
Original file line number Diff line number Diff line change @@ -13,3 +13,5 @@ type Text = T.Text
1313length = T. length
1414lines = T. lines
1515toStrict = id
16+ pack = T. pack
17+ unpack = T. unpack
Original file line number Diff line number Diff line change 77
88module Data.Text.Lazy.Builder where
99
10- type Builder = String
11- fromText = id
12- singleton = (: [] )
13- toLazyText = id
10+ import Data.String (IsString (.. ))
11+
12+ newtype Builder = Builder (String -> String )
13+
14+ instance IsString Builder where
15+ fromString s = Builder (s ++ )
16+
17+ instance Semigroup Builder where
18+ Builder a <> Builder b = Builder (a . b)
19+
20+ instance Monoid Builder where
21+ mempty = Builder id
22+
23+ fromText :: String -> Builder
24+ fromText t = Builder (t ++ )
25+
26+ singleton :: Char -> Builder
27+ singleton c = Builder ([c] ++ )
28+
29+ toLazyText :: Builder -> String
30+ toLazyText (Builder b) = b " "
Original file line number Diff line number Diff line change 44
55-- | Render an unannotated 'SimpleDocStream' as plain 'Text'.
66module Prettyprinter.Render.Text (
7- #ifdef MIN_VERSION_text
87 -- * Conversion to plain 'Text'
98 renderLazy , renderStrict ,
10- #endif
119
1210 -- * Render to a 'Handle'
1311 renderIO ,
Original file line number Diff line number Diff line change 1+ -- | This module is for use by packages that need to be able to use the prettyprinter package
2+ -- without incurring a dependency on the text package.
3+ --
4+ -- Legitimate examples of packages that must have text as an optional dependency, include text (or
5+ -- bytetring).
6+ module Prettyprinter.Util.Compat.Text
7+ ( module Data.Text
8+ ) where
9+
10+ import Data.Text
Original file line number Diff line number Diff line change 1+ -- | This module is for use by packages that need to be able to use the prettyprinter package
2+ -- without incurring a dependency on the text package.
3+ --
4+ -- Legitimate examples of packages that must have text as an optional dependency, include text (or
5+ -- bytetring).
6+ module Prettyprinter.Util.Compat.Text.IO
7+ ( module Data.Text.IO
8+ ) where
9+
10+ import Data.Text.IO
Original file line number Diff line number Diff line change 1+ -- | This module is for use by packages that need to be able to use the prettyprinter package
2+ -- without incurring a dependency on the text package.
3+ --
4+ -- Legitimate examples of packages that must have text as an optional dependency, include text (or
5+ -- bytetring).
6+ module Prettyprinter.Util.Compat.Text.Lazy
7+ ( module Data.Text.Lazy
8+ ) where
9+
10+ import Data.Text.Lazy
Original file line number Diff line number Diff line change 1+ -- | This module is for use by packages that need to be able to use the prettyprinter package
2+ -- without incurring a dependency on the text package.
3+ --
4+ -- Legitimate examples of packages that must have text as an optional dependency, include text (or
5+ -- bytetring).
6+ module Prettyprinter.Util.Compat.Text.Lazy.Builder
7+ ( module Data.Text.Lazy.Builder
8+ ) where
9+
10+ import Data.Text.Lazy.Builder
You can’t perform that action at this time.
0 commit comments