blancas.morph.monads documentation

->Either

(->Either left right)
Positional factory function for class blancas.morph.monads.Either.

->Identity

(->Identity value)
Positional factory function for class blancas.morph.monads.Identity.

->Maybe

(->Maybe value)
Positional factory function for class blancas.morph.monads.Maybe.

->Reader

(->Reader f)
Positional factory function for class blancas.morph.monads.Reader.

->State

(->State f)
Positional factory function for class blancas.morph.monads.State.

->Writer

(->Writer value output)
Positional factory function for class blancas.morph.monads.Writer.

ask

Returns a Reader whose value is the environment.

asks

(asks f)
Returns a Reader whose value the result of applying f
to the current environment.

either

macro

(either [v m] right-form)(either [v m] left-form right-form)
Evaluates m. If the result is Left, binds its Left contents
to v and evaluates left-form; otherwise binds its Right
contents to v and evaluates right-form.

eval-state

(eval-state m s)
Performs an action m with an initial state s. Returns the value.

eval-writer

(eval-writer m)
Returns the value of a writer.

exec-state

(exec-state m s)
Performs an action m with an initial state s. Returns the state.

exec-writer

(exec-writer m)
Returns the output of a writer.

get-state

Produces an action to return current state as the value.

gets

(gets f)
Like get-state, but applies the function f (usually a selector)
on the state being return as the value of the inner monad.

id

Alias for the Identity constructor.

just

(just x)
Maybe constructor. If x is not nil, it creates a Just value.
If x is nil it creates a Nothing.

just?

(just? m)
Checks for a maybe with a value.

justs

(justs coll)
Filters Just values from a collection. Returns unboxed values.

left

(left x)
Constructor for a Left value.

left?

(left? x)
Tests if the receiver is a Left value.

lefts

(lefts coll)
Extracts the Left values from a collection. Returns unboxed values.

listen

(listen m)
Allows chained Writers to peek at the current output w
by returning a value as a pair (v, w).

local

(local f m)
Returns a Reader whose value is the result of running the Reader m
under a changed environment, which is produced by applying f on
the previous environment.

make-either

macro

(make-either form)(make-either message form)(make-either message pred form)
Either constructor for a boxed value. It takes a value or a form
that may evaluate to nil or throw an exception, both of which
cases result in a Left value. Otherwise it is a Right value.

map-either

(map-either f coll)
Maps an Either-producing function over a collection.
Returns a sequence with Left values removed, as unboxed values.

map-maybe

(map-maybe f coll)
Maps a Maybe-producing function over a collection.
Filters out Nothing values and returns unboxed values.

may

macro

(may [x m] then-form)(may [x m] then-form else-form)
Like if-let for Maybe values. If m has a value, binds it to x
and evaluates the then-form. Otherwise, evaluates the optional
else-form.

maybe

macro

(maybe form)(maybe pred form)
Maybe constructor for a boxed value. It takes a value or a form
that may evaluate to nil or throw an exception, both of which
cases result in a Nothing value.

modify-state

(modify-state f & more)
Produces an action to apply f to the current state, using any
given (optional) arguments. The result becomes the new state.

nothing

Maybe constructor for no value.

nothing?

(nothing? m)
Checks for a maybe with nothing.

pass

(pass m)
Performs an action that returns a Writer similar to (listen),
but instead of output it adds an output-transforming function
to the value's pair. Returns a Writer whose output is the
result of that function.

put-state

(put-state s)
Produces an action to set the current state.

reader

(reader x)
The Reader monad constructor.

right

(right x)
Constructor for a Right value.

right?

(right? x)
Tests if the receiver is a Right value.

rights

(rights coll)
Extracts the Right values from a collection. Returns unboxed values.

run-id

(run-id m)
Returns the value held by an Identity type.

run-just

(run-just m)
Returns the boxed value of m.

run-left

(run-left m)
Accessor for the Left value.

run-reader

(run-reader m e)
Performs a Reader action m with an environment e.
Returns the value produced by the action.

run-right

(run-right m)
Accessor for the Right value.

run-state

(run-state m s)
Performs an action m with an initial state s.
Returns a pair with the value and the state.

state

(state x)
State monad constructor.

tell

(tell x)
Returns a Writer with output x.

writer

(writer a)(writer a w)
Writer monad constructor for value a and output w.
The value w must implement Monoid. If w is not
supplied, it defaults to the empty vector.