lens-3.9.0.2: Lenses, Folds and Traversals

Portability | non-portable
Stability | experimental
Maintainer | Edward Kmett <ekmett@gmail.com>
Safe Haskell | Trustworthy

Data.Text.Lens

Description

Synopsis

- class IsText t where
  - packed :: Iso' String t
  - builder :: Iso' t Builder
  - text :: IndexedTraversal' Int t Char
- unpacked :: IsText t => Iso' t String

# Documentation

class IsText t where

Traversals for strict or lazy `Text`

Methods

packed :: Iso' String t

This isomorphism can be used to `pack` (or `unpack`) strict or lazy `Text`.

     pack x ≡ x ^. packed
     unpack x ≡ x ^. from packed
     packed ≡ from unpacked

builder :: Iso' t Builder

Convert between strict or lazy `Text` and a `Builder`.

     fromText x ≡ x ^. builder

text :: IndexedTraversal' Int t Char

Traverse the individual characters in strict or lazy `Text`.

     text = unpacked . traversed

Instances

IsText Text |
IsText Text |

unpacked :: IsText t => Iso' t String

This isomorphism can be used to `unpack` (or `pack`) both strict or lazy `Text`.

     unpack x ≡ x ^. unpacked
     pack x ≡ x ^. from unpacked

This `Iso` is provided for notational convenience rather than out of great need, since

     unpacked ≡ from packed