Skip to content

Commit

Permalink
Add type synonyms for lazy and strict text flavours
Browse files Browse the repository at this point in the history
  • Loading branch information
Kleidukos committed Nov 27, 2023
1 parent dab73dd commit 353b4b0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Data/Text.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ module Data.Text

-- * Types
Text
, StrictText

-- * Creation and elimination
, pack
Expand Down Expand Up @@ -238,7 +239,7 @@ import qualified Data.Text.Internal.Fusion.Common as S
import Data.Text.Encoding (decodeUtf8', encodeUtf8)
import Data.Text.Internal.Fusion (stream, reverseStream, unstream)
import Data.Text.Internal.Private (span_)
import Data.Text.Internal (Text(..), empty, firstf, mul, safe, text, append, pack)
import Data.Text.Internal (Text(..), StrictText, empty, firstf, mul, safe, text, append, pack)
import Data.Text.Internal.Unsafe.Char (unsafeWrite, unsafeChr8)
import Data.Text.Show (singleton, unpack, unpackCString#, unpackCStringAscii#)
import qualified Prelude as P
Expand Down
4 changes: 4 additions & 0 deletions src/Data/Text/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module Data.Text.Internal
-- * Types
-- $internals
Text(..)
, StrictText
-- * Construction
, text
, textP
Expand Down Expand Up @@ -68,6 +69,9 @@ data Text = Text
{-# UNPACK #-} !Int -- ^ length in bytes (not in Char!), pointing to an end of UTF-8 sequence
deriving (Typeable)

-- | Type synonym for the strict flavour of 'Text'.
type StrictText = Text

-- | Smart constructor.
text_ ::
#if defined(ASSERTS)
Expand Down
4 changes: 4 additions & 0 deletions src/Data/Text/Internal/Lazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
module Data.Text.Internal.Lazy
(
Text(..)
, LazyText
, chunk
, empty
, foldrChunks
Expand Down Expand Up @@ -51,6 +52,9 @@ data Text = Empty
| Chunk {-# UNPACK #-} !T.Text Text
deriving (Typeable)

-- | Type synonym for the lazy flavour of 'Text'.
type LazyText = Text

-- $invariant
--
-- The data type invariant for lazy 'Text': Every 'Text' is either 'Empty' or
Expand Down

0 comments on commit 353b4b0

Please sign in to comment.