fclabels-1.1.4.3: First class accessor labels.

Safe Haskell | Safe-Inferred

Data.Label.Abstract

Synopsis

- data Point arr f i o = Point {
  - _get :: f `arr` o
  - _set :: (i, f) `arr` f
  }
- _modify :: ArrowApply arr => Point arr f i o -> (o `arr` i, f) `arr` f
- newtype Lens arr f a = Lens {
  - unLens :: Point arr f a a
  }
- lens :: (f `arr` a) -> ((a, f) `arr` f) -> Lens arr f a
- get :: Arrow arr => Lens arr f a -> f `arr` a
- set :: Arrow arr => Lens arr f a -> (a, f) `arr` f
- modify :: ArrowApply arr => Lens arr f o -> (o `arr` o, f) `arr` f
- bimap :: Arrow arr => (o' `arr` o) -> (i `arr` i') -> Point arr f i' o' -> Point arr f i o
- for :: Arrow arr => (i `arr` o) -> Lens arr f o -> Point arr f i o
- data Bijection arr a b = Bij {
  - fw :: a `arr` b
  - bw :: b `arr` a
  }
- liftBij :: Functor f => Bijection (->) a b -> Bijection (->) (f a) (f b)
- class Iso arr f where
  - iso :: Bijection arr a b -> f a `arr` f b
- osi :: Iso arr f => Bijection arr b a -> f a `arr` f b

# Documentation

data Point arr f i o Source

Abstract Point datatype. The getter and setter functions work in some arrow.

Constructors

Point |

Fields

_get :: f `arr` o
_set :: (i, f) `arr` f

Instances

Arrow arr => Functor (Point arr f i) |
Arrow arr => Applicative (Point arr f i) |

_modify :: ArrowApply arr => Point arr f i o -> (o `arr` i, f) `arr` fSource

Modification as a compositon of a getter and setter. Unfortunately, `ArrowApply` is needed for this composition.

newtype Lens arr f a Source

Abstract Lens datatype. The getter and setter functions work in some arrow. Arrows allow for effectful lenses, for example, lenses that might fail or use state.

Constructors

Lens |

Fields

unLens :: Point arr f a a

Instances

Arrow arr => Iso arr (Lens arr f) | We can diverge `Lens`es using an isomorphism.
ArrowApply arr => Category (Lens arr) |

lens :: (f `arr` a) -> ((a, f) `arr` f) -> Lens arr f aSource

Create a lens out of a getter and setter.

get :: Arrow arr => Lens arr f a -> f `arr` aSource

Get the getter arrow from a lens.

set :: Arrow arr => Lens arr f a -> (a, f) `arr` fSource

Get the setter arrow from a lens.

modify :: ArrowApply arr => Lens arr f o -> (o `arr` o, f) `arr` fSource

Get the modifier arrow from a lens.

bimap :: Arrow arr => (o' `arr` o) -> (i `arr` i') -> Point arr f i' o' -> Point arr f i oSource

Make a `Point` diverge in two directions.

for :: Arrow arr => (i `arr` o) -> Lens arr f o -> Point arr f i oSource

data Bijection arr a b Source

The bijections datatype, an arrow that works in two directions.

Constructors

Bij |

Fields

fw :: a `arr` b
bw :: b `arr` a

Instances

Arrow arr => Iso arr (Bijection arr a) | We can diverge `Bijection`s using an isomorphism.
Category arr => Category (Bijection arr) | Bijections as categories.

liftBij :: Functor f => Bijection (->) a b -> Bijection (->) (f a) (f b)Source

Lifting `Bijection`s.

class Iso arr f where Source

The isomorphism type class is like a `Functor` but works in two directions.

Methods

iso :: Bijection arr a b -> f a `arr` f bSource

Instances

Arrow arr => Iso arr (Bijection arr a) | We can diverge `Bijection`s using an isomorphism.
Arrow arr => Iso arr (Lens arr f) | We can diverge `Lens`es using an isomorphism.

osi :: Iso arr f => Bijection arr b a -> f a `arr` f bSource

Flipped isomorphism.