Control.Extend
- Package
- purescript-control
- Repository
- purescript/purescript-control
#Extend Source
class (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
#extendFlipped Source
extendFlipped :: forall b a w. Extend w => w a -> (w a -> b) -> w b
A version of extend
with its arguments flipped.
#composeCoKleisli Source
composeCoKleisli :: forall b a w c. Extend w => (w a -> b) -> (w b -> c) -> w a -> c
Forwards co-Kleisli composition.
#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)
Re-exports from Data.Functor
#Functor Source
class 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)