M.$1

static field

A shortcut of M.$n(1)

M.$2

static field

A shortcut of M.$n(2)

M.$3

static field

A shortcut of M.$n(3)

M.$4

static field

A shortcut of M.$n(4)

M.$n

static method

The placeholder of argument.

$F((x, y, z) => x + y + z)(M.$n(1), "6", M.$n(2))("7")("5");  // outputs "765"

M.Either.unit

static method

Monad 'unit' function.
This method is equivalent to M.Right(x).

M.F

static method

creates a function which can curry and compose.
First argument is a function to wrap and second argument is arity of the function.
If second argument is omitted, arity is equals to length of the first argument.

M.F((x, y, z) => x + y + z)(7)(6)(5);  // outputs 18

M.F.argumentsLength

method

returns arity of this function.

M.F.multiply

method

This method is equivalent to 'pipe'.

M.F.pipe

method

concatenates this function and the given function.
Arity of the given function must be 1.
The concatenated function can be curried.

M.F((x, y, z) => x + y + z).pipe(x => x + 2)(7)(6)(5);  // outputs 20

M.F.unit

static method

An identity function (I combinator).
M.F.I is an alias of this method.

M.F.value

method

unwraps this function.

M.Identity

static method

creates an identity monad with the given value.

M.Identity.bind

method

Monad 'bind' function.
This method simply apply the element to the given function.

M.Identity(4).bind(x => M.Identity(x + 2));  // outputs M.Identity(6)

M.Identity.multiply

method

This method is equivalent to 'bind'.

M.Identity.toString

method

returns the string representation of the holding value.

M.Identity.unit

static method

Monad 'unit' function.
This method is equivalent to M.Identity.

M.Identity.value

method

returns the element.

M.Just

static method

creates new Maybe Just monad with the given value.

M.Just.bind

method

Monad 'bind' function.
This method returns the result applying the wrapped value to the given function a → M.Maybe a.

M.Just(3).bind(x => M.Just(x * x));  // outputs M.Just(9)

M.Just.isNothing

method

always returns false.

M.Just.multiply

method

This method is equivalent to 'bind'.

M.Just.or

method

returns this monad.

M.Just(3).or(M.Just(4));  // output M.Just(3)

M.Just.value

method

returns a wrapped value.

M.Just(3).value();  // outputs 3

M.L

static method

creates a list from the given arguments.

M.L(3, 4, 6).at(1);   // outputs 4

M.L.at

method

gets an element at the specified index.

M.L.N(1).at(10);  // outputs 10

M.L.bind

method

Monad 'bind' function.
The first argument is a function whose input is element of list and output is M.L.

M.L(2, 7).bind(x => M.L(x + 2, x + 3));  // outputs M.L(4, 5, 9, 10)

M.L.combination

static method

returns a list which consists of k-combination of the array given by first argument.
Every element of the list is a tuple.
The number k is given by second argument.

M.L.combination(["a", "b", "c"], 2);  // outputs M.L(M.T("a", "b"), M.T("a", "c"), ...)

M.L.concat

method

concatenates the given list to this list.

M.L(3, 4).concat(M.L(6));  // outputs M.L(3, 4, 6)

M.L.create

static method

creates new list whose first value is the first arguement and rest value is the result of a thunk (a function with no arguments) given by second argument.

function succ(n) {
	return M.L.create(n, function() { return succ(n + 1); });
}
succ(1);  // outputs M.L(1, 2, 3, 4, 5, ...)

M.L.every

method

returns false if it exists that the element of this list applies to the function given by the first argument is falsy.
Notice: This method may not stop if elements of the list is infinity.

M.L(3, 4, 6).every(x => x % 2 === 0);  // outputs false

M.L.filter

method

returns new list which pass the test which is given the first argument.
This method is available when the list has infinity elements.

M.L.N(1).filter(x => x % 2 === 0);  // outputs M.L(2, 4, 6, ...)

M.L.isNull

method

returns true if this list is empty.

M.L.map

method

returns new list with the result of calling the function given by the argument on every element of this list.
This method is available when the list has infinite elements.

M.L.N(1).map(x => x * 2);  // outputs M.L(2, 4, 6, ...)

M.L.map

static method

returns new list with the result of calling the function given by the argument on every element of the lists.
This method is available when the list has infinite elements.

M.L.map((x, y, z) => x + y + z, M.L(1, 2, 3), M.L(3, 4, 5), M.L(6, 7));  // outputs M.L(10, 13)

M.L.multiply

method

This method is equivalent to 'bind'.

M.L.N

static method

returns an infinite list of natural number.
The first argument is first number.

M.L.N(0);  // outputs M.L(0, 1, 2, ...)

M.L.permutation

static method

returns a list which consist of k-permutation of the array given by first argument.
Every element of the list is a tuple.
The number k is given by second argument. If k is not given, k is the length of the given array.

M.L.permutation(["a", "b", "c"], 2);  // outputs M.L(M.T("a", "b"), M.T("a", "c"), ...)

M.L.power

static method

returns nth power list of the list given by first argument.
The number n is given by second argument.
A infinite list can give as an operand.

// outputs M.L(M.T("a", "a"), M.T("a", "b"), M.T("b", "a"), M.T("b", "b"))
M.L.power(M.L("a", "b"), 2);

M.L.product

static method

returns new list of cross product of the given lists.
A infinite list can give as an operand.

// outputs M.L(M.T(2, 3), M.T(4, 3), M.T(2, 6), M.T(6, 3), M.T(4, 6), M.T(6, 6))
M.L.product(M.L(2, 4, 6), M.L(3, 6));

M.L.range

static method

A list of integers which starts with first argument(inclusive) and ends with second argument(inclusive).

M.L.rest

method

gets rest of this list.

M.L(3, 4, 6).rest();  // outputs M.L(4, 6)

M.L.some

method

returns true if it exists that the element of this list applies to the function given by the first argument is truthy.
Notice: This method may not stop if elements of the list is infinity.

M.L(3, 4, 6).some(x => x % 2 === 0);  // outputs true

M.L.take

method

returns an array of first n elements.
If the argument is not given, returns an array of all elements.
Notice: This method may not stop if elements of the list is infinity.

M.L.N(2).take(5));  // outputs [2, 3, 4, 5, 6]

M.L.unit

static method

Monad 'unit' (or 'return') function.
The method returns new list which contains only the given element.

M.L.unit(9);  // outputs M.L(9)

M.L.value

method

gets first element.

M.L(3, 4, 6).value();  // outputs 3

M.L.Z

static field

A infinite list of integer.

M.L.zip

static method

returns new list with the tuples of the given lists.

M.L.zip(M.L(1, 2, 3), M.L(3, 4, 5), M.L(6, 7));  // outputs M.L(M.T(1, 3, 6), M.T(2, 4, 7))

M.Left.bind

method

Monad 'bind' function.
This method returns this monad.

M.Left(3).bind(x => M.Right(x * x));  // outputs M.Left(3)

M.Left.either

method

apply the holded value to function given by first argument.

M.Left(3).either(x => x + 2, x => x * 2);  // outputs 5

M.Left.multiply

method

This method is equivalent to 'bind'.

M.Left.or

method

returns the Either monad given by the first argument.

M.Left(3).or(M.Right(2));  // outputs M.Right(3)

M.Maybe.unit

static method

Monad 'unit' function.
This method is equivalent to M.Just(x).

M.Nil

static field

An empty list.

M.Nothing

static field

A Maybe Nothing monad.

M.Nothing.bind

method

Monad 'bind' function.
returns this monad.

M.Nothing.bind(x => M.Just(x * x));  // outputs M.Nothing

M.Nothing.isNothing

method

always returns true.

M.Nothing.multiply

method

This method is equivalent to 'bind'.

M.Nothing.or

method

returns the given argument.

M.Nothing.or(M.Just(4));  // outputs M.Just(4)

M.Nothing.value

method

always throws an error.

M.Right

static method

A Right monad of Either.

M.Right.bind

method

Monad 'bind' function.
This method returns the result applying the wrapped value to the given function a → M.Either a.

M.Right(3).bind(x => M.Right(x * x));  // outputs M.Right(9)

M.Right.either

method

apply the wrapped value to function given by second argument.

M.Right(3).either(x => x + 2, x => x * 2);  // outputs 6

M.Right.multiply

method

This method is equivalent to 'bind'.

M.Right.or

method

returns this monad.

M.Right(3).or(M.Left(2));  // outputs M.Right(3)

M.State

static method

creates new state monad.

M.State.bind

method

Monad 'bind' function.

M.State.evalState

method

returns the result value by executing this monad.

M.State.execState

method

returns the state by executing this monad.

M.State.getState

static field

A state monad which copies the state to the value.

M.State.modify

static method

creates new state monad which replaces the state to the result of calling the given function.

M.State.multiply

method

This method is equivalent to 'bind'.

M.State.putState

static method

creates new state monad which replaces the state to the given value.

M.State.runState

method

returns a tuple of the result and state by executing this monad.

M.State.unit

static method

Monad 'unit' function.
This method creates a state monad whose value is the given value.

M.StateT

static method

creates new state monad transformer.
This method has two curried arguments.
First argument is constructor of monad m, and second argument is a function a → m (v, s).

M.StateT.bind

method

Monad 'bind' function.

M.StateT.getState

field

A state monad transformer which copies the state to the value.

M.StateT.lift

method

lifts the given monad to state monad transformer.

M.StateT.modify

method

creates new state monad transformer which replaces the state to the result of calling the given function.

M.StateT.multiply

method

This method is equivalent to 'bind'.

M.StateT.putState

method

creates new state monad transformer which replaces the state to the given value.

M.StateT.runStateT

method

returns a tuple of the result and state by executing this monad.

M.StateT.unit

method

Monad 'unit' function.
This method creates a state monad transformer whose value is the given value.

M.T

static method

creates new tuple of the given elements.

M.T(1, 2, 3);  // outputs a tuple (1, 2, 3)

M.T.isTuple

static method

returns true is the given object is a tuple.

M.T.toArray

method

converts this tuple to an array.

M.T(1, 2, 3).toArray()  // outputs [1, 2, 3]

M.tu

static field

The 'do' notation.

M.tu($L(1, 2),
	x => $L(x * 2, x * 3),
	x => $L(x + 2, x + 3),
	x => $L(x * 2)).take();  // outputs [8, 10, 10, 12, 12, 14, 16, 18]