lens-5.2.3: Lenses, Folds and Traversals

Copyright | (C) 2012-16 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | experimental
Portability | non-portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

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
- _Text :: IsText t => Iso' t String
- pattern Text :: IsText s => String -> s

# Documentation

class IsText t where Source #

Traversals for strict or lazy `Text`

Minimal complete definition

packed, builder

Methods

packed :: Iso' String t Source #

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 Source #

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

    fromText x ≡ x ^. builder

text :: IndexedTraversal' Int t Char Source #

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

    text = unpacked . traversed

#### Instances

Instances details

IsText Text Source # |
Instance details Defined in Data.Text.Lens Methods packed :: Iso' String Text Source # builder :: Iso' Text Builder Source # text :: IndexedTraversal' Int Text Char Source #
IsText Text Source # |
Instance details Defined in Data.Text.Lens Methods packed :: Iso' String Text Source # builder :: Iso' Text Builder Source # text :: IndexedTraversal' Int Text Char Source #
IsText String Source # |
Instance details Defined in Data.Text.Lens Methods packed :: Iso' String String Source # builder :: Iso' String Builder Source # text :: IndexedTraversal' Int String Char Source #

unpacked :: IsText t => Iso' t String Source #

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

_Text :: IsText t => Iso' t String Source #

This is an alias for `unpacked` that makes it clearer how to use it with `(`#`)`.

    _Text = from packed

    >>> _Text # "hello" :: Strict.Text
    "hello"

pattern Text :: IsText s => String -> s Source #