fclabels-2.0.3.2: First class accessor labels implemented as lenses.

Safe Haskell | None
Language | Haskell98

Data.Label.Base

Contents

- Lenses for lists.
- Lenses for Either.
- Lens for Maybe.
- Lenses for 2-tuples.
- Lenses for 3-tuples.
- Read/Show isomorphism.

Description

Labels for data types in the base package. The lens types are kept abstract to be fully reusable in custom contexts. Build to be imported qualified.

Synopsis

- head :: (ArrowZero arr, ArrowApply arr, ArrowChoice arr) => Lens arr [a] a
- tail :: (ArrowZero arr, ArrowApply arr, ArrowChoice arr) => Lens arr [a] [a]
- left :: (ArrowZero arr, ArrowApply arr, ArrowChoice arr) => Lens arr (Either a b -> Either o b) (a -> o)
- right :: (ArrowZero arr, ArrowApply arr, ArrowChoice arr) => Lens arr (Either a b -> Either a o) (b -> o)
- just :: (ArrowChoice cat, ArrowZero cat, ArrowApply cat) => Lens cat (Maybe a -> Maybe b) (a -> b)
- fst :: ArrowApply arr => Lens arr ((a, b) -> (o, b)) (a -> o)
- snd :: ArrowApply arr => Lens arr ((a, b) -> (a, o)) (b -> o)
- swap :: ArrowApply arr => Lens arr ((a, b) -> (c, d)) ((b, a) -> (d, c))
- fst3 :: ArrowApply arr => Lens arr ((a, b, c) -> (o, b, c)) (a -> o)
- snd3 :: ArrowApply arr => Lens arr ((a, b, c) -> (a, o, c)) (b -> o)
- trd3 :: ArrowApply arr => Lens arr ((a, b, c) -> (a, b, o)) (c -> o)
- readShow :: (Read a, Show a) => Iso Partial String a

# Lenses for lists.

head :: (ArrowZero arr, ArrowApply arr, ArrowChoice arr) => Lens arr [a] a #

Lens pointing to the head of a list's cons cell. (Partial and monomorphic)

tail :: (ArrowZero arr, ArrowApply arr, ArrowChoice arr) => Lens arr [a] [a] #

Lens pointing to the tail of a list's cons cell. (Partial and monomorphic)

# Lenses for Either.

left :: (ArrowZero arr, ArrowApply arr, ArrowChoice arr) => Lens arr (Either a b -> Either o b) (a -> o) #

Lens pointing to the left value in an Either. (Partial and polymorphic)

right :: (ArrowZero arr, ArrowApply arr, ArrowChoice arr) => Lens arr (Either a b -> Either a o) (b -> o) #

Lens pointing to the right value in an Either. (Partial and polymorphic)

# Lens for Maybe.

just :: (ArrowChoice cat, ArrowZero cat, ArrowApply cat) => Lens cat (Maybe a -> Maybe b) (a -> b) #

Lens pointing to the value in a Maybe. (Partial and polymorphic)

# Lenses for 2-tuples.

fst :: ArrowApply arr => Lens arr ((a, b) -> (o, b)) (a -> o) #

Lens pointing to the first component of a 2-tuple. (Total and polymorphic)

snd :: ArrowApply arr => Lens arr ((a, b) -> (a, o)) (b -> o) #

Lens pointing to the second component of a 2-tuple. (Total and polymorphic)

swap :: ArrowApply arr => Lens arr ((a, b) -> (c, d)) ((b, a) -> (d, c)) #

Polymorphic lens that swaps the components of a tuple. (Total and polymorphic)

# Lenses for 3-tuples.

fst3 :: ArrowApply arr => Lens arr ((a, b, c) -> (o, b, c)) (a -> o) #

Lens pointing to the first component of a 3-tuple. (Total and polymorphic)

snd3 :: ArrowApply arr => Lens arr ((a, b, c) -> (a, o, c)) (b -> o) #

Lens pointing to the second component of a 3-tuple. (Total and polymorphic)

trd3 :: ArrowApply arr => Lens arr ((a, b, c) -> (a, b, o)) (c -> o) #

Lens pointing to the third component of a 3-tuple. (Total and polymorphic)

# Read/Show isomorphism.

readShow :: (Read a, Show a) => Iso Partial String a #

Partial isomorphism for readable and showable values. Can easily be lifted into a lens by using `iso`.