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
closes #317
  • Loading branch information
Kleidukos authored and Lysxia committed Dec 13, 2023
1 parent dab73dd commit fb3aed2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
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
3 changes: 2 additions & 1 deletion src/Data/Text/Lazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module Data.Text.Lazy

-- * Types
Text
, LazyText

-- * Creation and elimination
, pack
Expand Down Expand Up @@ -230,7 +231,7 @@ import qualified Data.Text.Internal.Lazy.Fusion as S
import Data.Text.Internal.Fusion.Types (PairS(..))
import Data.Text.Internal.Lazy.Fusion (stream, unstream)
import Data.Text.Internal.Lazy (Text(..), chunk, empty, foldlChunks,
foldrChunks, smallChunkSize, defaultChunkSize, equal)
foldrChunks, smallChunkSize, defaultChunkSize, equal, LazyText)
import Data.Text.Internal (firstf, safe, text)
import Data.Text.Lazy.Encoding (decodeUtf8', encodeUtf8)
import Data.Text.Internal.Lazy.Search (indices)
Expand Down

0 comments on commit fb3aed2

Please sign in to comment.