blancas.morph.core documentation

->All

(->All all)
Positional factory function for class blancas.morph.core.All.

->Any

(->Any any)
Positional factory function for class blancas.morph.core.Any.

->Pair

(->Pair fst snd)
Positional factory function for class blancas.morph.core.Pair.

->Product

(->Product product)
Positional factory function for class blancas.morph.core.Product.

->Sum

(->Sum sum)
Positional factory function for class blancas.morph.core.Sum.

<$

(<$ value functor)
Maps a functor to the same value.

<*>

(<*> af f & more)
Applies the receiver to the rest of the arguments. Unlike (app),
this function takes a variable number of arguments.

<<

(<< p q)(<< p q & more)
Performs two or more actions; keeps the result of the first.

>>

(>> m k)(>> m k & more)
Performs two or more actions; ignores the result of the first.

>>=

(>>= m k)
Performs computation m and applies k to the result. Function k
must return a monadic type.

Applicative

A functor with application, providing operations to embed pure
expressions and sequence computations to combine their results.

Functor

The Functor protocol is used for types that can be mapped over.
Instances of Functor should satisfy the following laws:

fmap id  ==  id
fmap (f . g)  ==  fmap f . fmap g

Monad

A monadic type supports the chaining of sequential actions.

MonadPlus

Monads that support choice and failure; should satisfy:

mzero >>= f  =  mzero
v >> mzero   =  mzero

Monoid

Monoids have an associative binary operator with an identity value.

all

(all s)
Accessor for the All type.

all-id

The identity value for the All monoid.

any

(any s)
Accessor for the Any type.

any-id

The identity value for the Any monoid.

app

(app this x)
Applies the first functor on its argument, which is either
a single value of a collection.

curry

macro

(curry f)(curry f n)
Returns a curried version of a function. Variadic functions
must supplied the number of arguments.

defcurry

macro

(defcurry fname & [f1 & fs :as all])
Defines a curried function that may be called as a partial
or total function using the regular function-call notation.
Partial applications yield functions that work the same way.
When all arguments have been given it evaluates the body
and returns its value. Takes an optional docstring, as defn.

flip

(flip f)
Returns a version of f with its first two arguments reversed.

fmap

(fmap function functor)
A version of (fun) where the functor is last.

fst

(fst p)
Accessor for the first element of a pair.

fun

(fun this f)
Applies a function to a functor's data, producing a new functor.

liftm

(liftm f m)
Lifts a one-arg function to work with monads.

liftm2

(liftm2 f m1 m2)
Lifts a two-arg function to work with monads.

liftm3

(liftm3 f m1 m2 m3)
Lifts a three-arg function to work with monads.

liftm4

(liftm4 f m1 m2 m3 m4)
Lifts a four-arg function to work with monads.

mapm

(mapm f coll)
Maps a one-arg monad constructor over a collection of values.
Then it executes the actions in a sequence with (seqm).

mappend

(mappend this x)
Applies the operator defined by the instance on this and x.

mcf

macro

(mcf args & body)
Makes a curried function off the arglist and body.

mconcat

(mconcat coll)
Reduces the collection of monoids using their defined
mappend for accumulation and mempty as initial value.

mempty

(mempty this)
Returns the identity value of the receiver. Though this is actually
a constructor, implementing this function makes it possible to write
generic functions over monoids.

monad

macro

(monad [& bindings] & body)
Monadic binding that expands into nested >>= forms and a function body.

The pattern:

(>>= p1 (fn [v1]
(>>= p2 (fn [v2]
...
  (return (f v1 v2 ...))))))

can be more conveniently be written as:

(monad [v1 p1 v2 p2 ...] (return (f v1 v2 ...)))

mplus

(mplus this m)
An associative operation with identity value mzero.

mzero

(mzero this)
Creates an identity value of type this with value x.
The receiver is used to dispatch the right constructor.

prod-id

The identity value for the Product monoid.

product

(product s)
Accessor for a Product type.

return

(return this x)
Creates a monadic value of type this with value x. The receiver
object is not used except for dispatching the right constructor.

seqm

(seqm coll)
Executes actions in sequence; collects the results in a vector.
The result is a new monad with the vector as its value. The
collection argument must not be empty.

seqm_

(seqm_ ms)
Executes actions in sequence, ignoring the results.
The result is a new monad with an empty vector as its value.

snd

(snd p)
Accessor for the second element of a pair.

sum

(sum s)
Accessor for a Sum type.

sum-id

The identity value for the Sum monoid.