Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

monad

monad

§monad(A 
type
, MA 
type
:monad monad.A monad.MA)
 => 
monad monad.A monad.MA
:
Any 

monad -- generic monad

A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.

Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.

Functions

§join(MMA 
type
:monad monad.MA (monad monad.A monad.MA), a monad.join.MMA)
 => 
monad.MA
:
Any 
join operator

NYI: useless since redefinition currently not supported for
feature with generics.
monadic operator within the same monad

Apply f to elements of type A and re-wrap them in this monad.
§infix >>=~(B 
type
, MB 
type
, f Unary (monad.infix >>=~.MB) monad.A)
 => 
monad.infix >>=~.MB
:
Any 
monadic operator to another monad

Apply f to elements of type A and wrap them in MB.

NYI: This is currently useless since a redefinition is not
allowed for features with generic arguments. Is there a way
we could allow this anyway?

Type Features

§type.return(a monad.type.A)
 => 
monad.type.MA
:
Any 
return function