Liking cljdoc? Tell your friends :D

blancas.morph.monads

Basic Monads.

Basic Monads.
raw docstring

askclj

Returns a Reader whose value is the environment.

Returns a Reader whose value is the environment.
sourceraw docstring

asksclj

(asks f)

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

Returns a Reader whose value the result of applying f
to the current environment.
sourceraw docstring

eithercljmacro

(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.

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.
sourceraw docstring

eval-stateclj

(eval-state m s)

Performs an action m with an initial state s. Returns the value.

Performs an action m with an initial state s. Returns the value.
sourceraw docstring

eval-writerclj

(eval-writer m)

Returns the value of a writer.

Returns the value of a writer.
sourceraw docstring

exec-stateclj

(exec-state m s)

Performs an action m with an initial state s. Returns the state.

Performs an action m with an initial state s. Returns the state.
sourceraw docstring

exec-writerclj

(exec-writer m)

Returns the output of a writer.

Returns the output of a writer.
sourceraw docstring

get-stateclj

Produces an action to return current state as the value.

Produces an action to return current state as the value.
sourceraw docstring

getsclj

(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.

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

idclj

Alias for the Identity constructor.

Alias for the Identity constructor.
sourceraw docstring

justclj

(just x)

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

Maybe constructor. If x is not nil, it creates a Just value.
If x is nil it creates a Nothing.
sourceraw docstring

just?clj

(just? m)

Checks for a maybe with a value.

Checks for a maybe with a value.
sourceraw docstring

justsclj

(justs coll)

Filters Just values from a collection. Returns unboxed values.

Filters Just values from a collection. Returns unboxed values.
sourceraw docstring

leftclj

(left x)

Constructor for a Left value.

Constructor for a Left value.
sourceraw docstring

left?clj

(left? x)

Tests if the receiver is a Left value.

Tests if the receiver is a Left value.
sourceraw docstring

leftsclj

(lefts coll)

Extracts the Left values from a collection. Returns unboxed values.

Extracts the Left values from a collection. Returns unboxed values.
sourceraw docstring

listenclj

(listen m)

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

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

localclj

(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.

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.
sourceraw docstring

make-eithercljmacro

(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.

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.
sourceraw docstring

map-eitherclj

(map-either f coll)

Maps an Either-producing function over a collection. Returns a sequence with Left values removed, as unboxed values.

Maps an Either-producing function over a collection.
Returns a sequence with Left values removed, as unboxed values.
sourceraw docstring

map-maybeclj

(map-maybe f coll)

Maps a Maybe-producing function over a collection. Filters out Nothing values and returns unboxed values.

Maps a Maybe-producing function over a collection.
Filters out Nothing values and returns unboxed values.
sourceraw docstring

maycljmacro

(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.

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.
sourceraw docstring

maybecljmacro

(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.

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.
sourceraw docstring

modify-stateclj

(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.

Produces an action to apply f to the current state, using any
given (optional) arguments. The result becomes the new state.
sourceraw docstring

nothingclj

Maybe constructor for no value.

Maybe constructor for no value.
sourceraw docstring

nothing?clj

(nothing? m)

Checks for a maybe with nothing.

Checks for a maybe with nothing.
sourceraw docstring

passclj

(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.

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.
sourceraw docstring

put-stateclj

(put-state s)

Produces an action to set the current state.

Produces an action to set the current state.
sourceraw docstring

readerclj

(reader x)

The Reader monad constructor.

The Reader monad constructor.
sourceraw docstring

(right x)

Constructor for a Right value.

Constructor for a Right value.
sourceraw docstring

right?clj

(right? x)

Tests if the receiver is a Right value.

Tests if the receiver is a Right value.
sourceraw docstring

rightsclj

(rights coll)

Extracts the Right values from a collection. Returns unboxed values.

Extracts the Right values from a collection. Returns unboxed values.
sourceraw docstring

run-idclj

(run-id m)

Returns the value held by an Identity type.

Returns the value held by an Identity type.
sourceraw docstring

run-justclj

(run-just m)

Returns the boxed value of m.

Returns the boxed value of m.
sourceraw docstring

run-leftclj

(run-left m)

Accessor for the Left value.

Accessor for the Left value.
sourceraw docstring

run-readerclj

(run-reader m e)

Performs a Reader action m with an environment e. Returns the value produced by the action.

Performs a Reader action m with an environment e.
Returns the value produced by the action.
sourceraw docstring

run-rightclj

(run-right m)

Accessor for the Right value.

Accessor for the Right value.
sourceraw docstring

run-stateclj

(run-state m s)

Performs an action m with an initial state s. Returns a pair with the value and the state.

Performs an action m with an initial state s.
Returns a pair with the value and the state.
sourceraw docstring

stateclj

(state x)

State monad constructor.

State monad constructor.
sourceraw docstring

tellclj

(tell x)

Returns a Writer with output x.

Returns a Writer with output x.
sourceraw docstring

writerclj

(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.

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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close