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

Safe Haskell | Safe
Language | Haskell98

Data.Label.Point

Contents

- The point data type that generalizes lens.
- Working with isomorphisms.
- Specialized lens contexts.
- Arrow type class for failing with some error.
- Orphan instances

Description

The Point data type which generalizes the different lenses and forms the basis for vertical composition using the `Applicative` type class.

Synopsis

- data Point cat g i f o = Point (cat f o) (cat (cat o i, f) g)
- get :: Point cat g i f o -> cat f o
- modify :: Point cat g i f o -> cat (cat o i, f) g
- set :: Arrow arr => Point arr g i f o -> arr (i, f) g
- identity :: ArrowApply arr => Point arr f f o o
- compose :: ArrowApply cat => Point cat t i b o -> Point cat g t f b -> Point cat g i f o
- data Iso cat i o = Iso {
  - fw :: cat i o
  - bw :: cat o i
  }
- inv :: Iso cat i o -> Iso cat o i
- type Total = (->)
- type Partial = Kleisli Maybe
- type Failing e = Kleisli (Either e)
- class Arrow a => ArrowFail e a where

# The point data type that generalizes lens.

data Point cat g i f o #

Abstract Point datatype. The getter and modifier operations work in some category. The type of the value pointed to might change, thereby changing the type of the outer structure.

Constructors

Point (cat f o) (cat (cat o i, f) g) |

Instances

Arrow arr => Functor (Point arr f i f) # |
Methods fmap :: (a -> b) -> Point arr f i f a -> Point arr f i f b # (<$) :: a -> Point arr f i f b -> Point arr f i f a #
Arrow arr => Applicative (Point arr f i f) # |
Methods pure :: a -> Point arr f i f a # (<*>) :: Point arr f i f (a -> b) -> Point arr f i f a -> Point arr f i f b # (*>) :: Point arr f i f a -> Point arr f i f b -> Point arr f i f b # (<*) :: Point arr f i f a -> Point arr f i f b -> Point arr f i f a #
Alternative (Point Partial f view f) # |
Methods empty :: Point Partial f view f a # (<|>) :: Point Partial f view f a -> Point Partial f view f a -> Point Partial f view f a # some :: Point Partial f view f a -> Point Partial f view f [a] # many :: Point Partial f view f a -> Point Partial f view f [a] #

get :: Point cat g i f o -> cat f o #

Get the getter category from a Point.

modify :: Point cat g i f o -> cat (cat o i, f) g #

Get the modifier category from a Point.

set :: Arrow arr => Point arr g i f o -> arr (i, f) g #

Get the setter category from a Point.

identity :: ArrowApply arr => Point arr f f o o #

Identity Point. Cannot change the type.

compose :: ArrowApply cat => Point cat t i b o -> Point cat g t f b -> Point cat g i f o #

Point composition.

# Working with isomorphisms.

data Iso cat i o infix 8 #

An isomorphism is like a `Category` that works in two directions.

Constructors

Iso infix 8 |
Fields fw :: cat i o bw :: cat o i

Instances

Category * cat => Category * (Iso cat) # | Isomorphisms are categories.
Methods id :: cat a a # (.) :: cat b c -> cat a b -> cat a c #

inv :: Iso cat i o -> Iso cat o i #

Flip an isomorphism.

# Specialized lens contexts.

type Total = (->) #

Context that represents computations that always produce an output.

type Partial = Kleisli Maybe #

Context that represents computations that might silently fail.

type Failing e = Kleisli (Either e) #

Context that represents computations that might fail with some error.

# Arrow type class for failing with some error.

class Arrow a => ArrowFail e a where #

The ArrowFail class is similar to `ArrowZero`, but additionally embeds some error value in the computation instead of throwing it away.

Minimal complete definition

failArrow

Methods

failArrow :: a e c #

Instances

ArrowFail e Partial # |
Methods failArrow :: Partial e c #
ArrowFail e (Failing e) # |
Methods failArrow :: Failing e e c #

# Orphan instances

Functor f => Functor (Kleisli f i) # | Missing Functor instance for Kleisli.
Methods fmap :: (a -> b) -> Kleisli f i a -> Kleisli f i b # (<$) :: a -> Kleisli f i b -> Kleisli f i a #
Applicative f => Applicative (Kleisli f i) # | Missing Applicative instance for Kleisli.
Methods pure :: a -> Kleisli f i a # (<*>) :: Kleisli f i (a -> b) -> Kleisli f i a -> Kleisli f i b # (*>) :: Kleisli f i a -> Kleisli f i b -> Kleisli f i b # (<*) :: Kleisli f i a -> Kleisli f i b -> Kleisli f i a #
Alternative f => Alternative (Kleisli f i) # | Missing Alternative instance for Kleisli.
Methods empty :: Kleisli f i a # (<|>) :: Kleisli f i a -> Kleisli f i a -> Kleisli f i a # some :: Kleisli f i a -> Kleisli f i [a] # many :: Kleisli f i a -> Kleisli f i [a] #