"Go monadic" is a functional programming library for Go. It's purpose is to provide basic monad implementations to support functional programming approaches in Go.
- Maybe
This section describes the API of the library and how to use it.
The Maybe
monad encapsulates a value and provides functions to Map
the value and
to compose it with other functions returning a value of the Maybe
type through Bind
.
Maybe
can be in two states: Just
and Nothing
. In the Just
state it's containing
an actual value. In the Nothing
state it's empty.
To create a value of Maybe
there are two ways:
functional.Just[int, int](42)
: This creates aMaybe
containing a valuefunctional.Nothing[int, int]
: This creates an emptyMaybe