Module

Control.Extend

Package
purescript-control
Repository
purescript/purescript-control

#Extend Source

class Extend :: (Type -> Type) -> Constraintclass (Functor w) <= Extend w  where

The Extend class defines the extension operator (<<=) which extends a local context-dependent computation to a global computation.

Extend is the dual of Bind, and (<<=) is the dual of (>>=).

Laws:

  • Associativity: extend f <<< extend g = extend (f <<< extend g)

Members

  • extend :: forall b a. (w a -> b) -> w a -> w b

Instances

#(<<=) Source

Operator alias for Control.Extend.extend (right-associative / precedence 1)

#extendFlipped Source

extendFlipped :: forall b a w. Extend w => w a -> (w a -> b) -> w b

A version of extend with its arguments flipped.

#(=>>) Source

Operator alias for Control.Extend.extendFlipped (left-associative / precedence 1)

#composeCoKleisli Source

composeCoKleisli :: forall b a w c. Extend w => (w a -> b) -> (w b -> c) -> w a -> c

Forwards co-Kleisli composition.

#(=>=) Source

Operator alias for Control.Extend.composeCoKleisli (right-associative / precedence 1)

#composeCoKleisliFlipped Source

composeCoKleisliFlipped :: forall b a w c. Extend w => (w b -> c) -> (w a -> b) -> w a -> c

Backwards co-Kleisli composition.

#(=<=) Source

Operator alias for Control.Extend.composeCoKleisliFlipped (right-associative / precedence 1)

#duplicate Source

duplicate :: forall a w. Extend w => w a -> w (w a)

Duplicate a comonadic context.

duplicate is dual to Control.Bind.join.

Re-exports from Data.Functor

#Functor Source

class Functor :: (Type -> Type) -> Constraintclass Functor f  where

A Functor is a type constructor which supports a mapping operation map.

map can be used to turn functions a -> b into functions f a -> f b whose argument and return types use the type constructor f to represent some computational context.

Instances must satisfy the following laws:

  • Identity: map identity = identity
  • Composition: map (f <<< g) = map f <<< map g

Members

  • map :: forall a b. (a -> b) -> f a -> f b

Instances

#void Source

void :: forall f a. Functor f => f a -> f Unit

The void function is used to ignore the type wrapped by a Functor, replacing it with Unit and keeping only the type information provided by the type constructor itself.

void is often useful when using do notation to change the return type of a monadic computation:

main = forE 1 10 \n -> void do
  print n
  print (n * n)

#(<$>) Source

Operator alias for Data.Functor.map (left-associative / precedence 4)

#(<$) Source

Operator alias for Data.Functor.voidRight (left-associative / precedence 4)

#(<#>) Source

Operator alias for Data.Functor.mapFlipped (left-associative / precedence 1)

#($>) Source

Operator alias for Data.Functor.voidLeft (left-associative / precedence 4)