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

monad

🌌monad

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.
-- Saunder Mac Lane, Categories for the Working Mathematician, 1971

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

monadic operator within the same monad

Apply f to elements of type A and re-wrap them in this monad.

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?

§join<MMA>(a MMA)
 => 
MA
:
Object

join operator

NYI: useless since redefinition currently not supported for
feature with generics.

§return(a A)
 => 
MA
:
Object

return function

NYI: This should be A -> MA, not MA x A -> MA as it is right now
since it needs an instance to be called on.