| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Data.Fmt.Text.Lazy
Description
Lazy Text as Mu (Cons StrictText).
Lazy Text is internally a linked list of strict chunks:
data Text = Empty | Chunk !StrictText Text
This is exactly Fix (Cons StrictText). This module provides
conversions and operations that let you apply the full recursion
scheme and streaming metamorphism infrastructure to lazy Text.
Synopsis
- toChunks :: Text -> Mu (Cons Text)
- fromChunks :: Mu (Cons Text) -> Text
- toNuChunks :: Text -> Nu (Cons Text)
- foldChunks :: Algebra (Cons Text) a -> Text -> a
- unfoldChunks :: Coalgebra (Cons Text) a -> a -> Text
- refoldChunks :: Algebra (Cons Text) b -> Coalgebra (Cons Text) a -> a -> b
- mapChunks :: (Text -> Text) -> Text -> Text
- streamChunks :: (Mu (Cons Text) -> Mu (Cons Text)) -> Text -> Text
- transformChunks :: (Mu (Cons Text) -> Mu (Cons a)) -> Text -> [a]
Conversion
fromChunks :: Mu (Cons Text) -> Text Source #
Reassemble a Mu (Cons Text) into a lazy Text.
O(n) — folds the Church-encoded list back into chunks.
toNuChunks :: Text -> Nu (Cons Text) Source #
View a lazy Text as Nu (Cons Text) for lazy streaming.
O(1) construction — the Text itself is the seed.
Folding
foldChunks :: Algebra (Cons Text) a -> Text -> a Source #
Fold a lazy Text chunk by chunk.
foldChunks alg = fold alg . toChunks
Unfolding
unfoldChunks :: Coalgebra (Cons Text) a -> a -> Text Source #
Build a lazy Text from a seed, one chunk at a time.
unfoldChunks coalg = fromChunks . unfold coalg
Refold
refoldChunks :: Algebra (Cons Text) b -> Coalgebra (Cons Text) a -> a -> b Source #
Unfold then fold, fused — no intermediate Mu structure.