Eff
The Eff
monad
Represents synchronous computations which are both dependency-injected and explicitly effectful
new Eff()
Static Members
of :: a -> Eff e a
Parameters
Returns
Eff<any, A>
Require :: () -> Eff e e
Returns
Eff<E, E>
Requires :: (e -> a) -> Eff e a
Requires(f: function (e: E): A):
Eff<E, A>
Parameters
Returns
Eff<E, A>
Instance Members
map :: Eff e a ~> (a -> b) -> Eff e b
Transforms the result of the Eff
instance
map(transform: function (a: A): B):
Eff<E, B>
Parameters
transform (function (a: A): B)
Returns
Eff<E, B>
andThen :: Eff e a ~> (a -> Eff f b) -> Eff (e & f) b
Chains the result of the Eff
instance to another Eff
-producing function
andThen(next: function (a: A):
Eff<F, B>):
Eff<any, B>
Parameters
next (function (a: A): Eff<F, B>)
Returns
Eff<any, B>
toEffResult :: Eff e a ~> () -> EffResult e a x
Returns the Eff
instance converted to an EffResult
Returns
EffResult<E, A, any>
toEffTask :: Eff e a ~> () -> EffTask e a x
Returns the Eff
instance converted to an EffTask
Returns
EffTask<E, A, any>
EffResult
The EffResult
monad
new EffResult()
Static Members
fromEff :: Eff e a -> EffResult e a x
Parameters
Returns
EffResult<E, A, any>
fromResult :: Result a x -> EffResult {} a x
Parameters
Returns
EffResult<{}, A, X>
of :: a -> EffResult {} a x
Parameters
Returns
EffResult<any, A, any>
Require :: () -> EffResult e e x
Returns
EffResult<E, E, any>
Requires :: (e -> Result a x ) -> EffResult e a x
Parameters
f (function (e: E): Result<A, X>)
Returns
EffResult<E, A, X>
Val :: a -> Result e a x
Parameters
Returns
EffResult<any, A, any>
Err :: x -> Result e a x
Parameters
Returns
EffResult<any, any, X>
Instance Members
map :: EffResult e a x ~> (a -> b) -> EffResult e b x
map(f: function (a: A): B):
EffResult<E, B, X>
Parameters
Returns
EffResult<E, B, X>
andThen :: EffResult e a x ~> (a -> EffResult f b x) -> EffResult (e & f) b x
Parameters
Returns
EffResult<any, B, X>
toEffTask :: EffResult e a x ~> () -> EffTask e a x
Returns
EffTask<E, A, X>
EffTask
The EffTask
monad
new EffTask()
Static Members
fromEff :: Eff e a -> EffTask e a x
Returns the given Eff
converted to an EffTask
Parameters
Returns
EffTask<E, A, any>
fromEffResult :: EffResult e a x -> EffTask e a x
Returns the given EffResult
converted to an EffTask
Parameters
Returns
EffTask<E, A, X>
fromTask :: Task a x -> EffTask {} a x
Returns the given Task
converted to an EffTask
Parameters
Returns
EffTask<{}, A, X>
of :: a -> EffTask {} a x
Parameters
Returns
EffTask<any, A, any>
Require :: () -> EffTask e e x
Returns
EffTask<E, E, any>
Requires :: (e -> Task a x) -> EffTask e a x
Requires(f: function (e: E):
Task<A, X>):
EffTask<E, A, X>
Parameters
f (function (e: E): Task<A, X>)
Returns
EffTask<E, A, X>
Success :: a -> EffTask e a x
Returns an EffTask
that always succeeds with the given value
Success(a: A):
EffTask<any, A, any>
Parameters
Returns
EffTask<any, A, any>
Fail :: x -> EffTask e a x
Returns an EffTask
that always fails with the given value
Parameters
Returns
EffTask<any, any, X>
Instance Members
map :: EffTask e a x ~> (a -> b) -> EffTask e b x
Transforms the result of the EffTask
instance if successful,
and otherwise propagates the failure
map(f: function (a: A): B):
EffTask<E, B, X>
Parameters
Returns
EffTask<E, B, X>
andThen :: EffTask e a x ~> (a -> EffTask f b x) -> EffTask e b x
Parameters
next (function (a: A): EffTask<F, B, X>)
Returns
EffTask<any, B, X>
Identity
The Identity
monad
Simply acts a container for values without any additional behavior
new Identity()
Example
let a = Identity.of(42)
Static Members
of :: a -> Identity a
Returns an Identity
instance wrapping the giving value
Parameters
Returns
Identity<A>
lift :: (a -> b) -> Identity a -> Identity b
Parameters
Returns
function (a: Identity<A>): Identity<B>
lift2 :: (a -> b -> c) -> (Identity a -> Identity b) -> Identity c
Parameters
f (function (a: A, b: B): C)
Returns
function (a: Identity<A>, b: Identity<B>): Identity<C>
lift3 :: (a -> b -> c -> d) -> (Identity a -> Identity b -> Identity c) -> Identity d
Parameters
f (function (a: A, b: B, c: C): D)
Returns
function (a: Identity<A>, b: Identity<B>, c: Identity<C>): Identity<D>
Instance Members
map :: Identity a ~> (a -> b) -> Identity b
Transforms the value in the Identity
instance
map(transform: function (a: A): B):
Identity<B>
Parameters
transform (function (a: A): B)
Returns
Identity<B>
andThen :: Identity a ~> (a -> Identity b) -> Identity b
Chains the value of the Identity
instance
with another Identity
-producing function
Parameters
Returns
Identity<B>
toString :: Identity a ~> () -> String
Returns a string representation of the Identity
instance
Returns
string
IO
The IO
monad
Represents a potentially-effectful synchronous computation
new IO()
Static Members
of :: a -> IO a
Returns an IO
instance that always produces the given value
Parameters
Returns
IO<A>
lift :: (a -> b) -> IO a -> IO b
Takes an unary function an returns an equivalent unary function which operates on IO
values
lift(f: function (t: A): B): function (t:
IO<A>):
IO<B>
Parameters
Returns
function (t: IO<A>): IO<B>
lift2 :: (a -> b -> c) -> IO a -> IO b -> IO c
Takes an binary function an returns an equivalent binary function which operates on IO
values
lift2(f: function (a: A, b: B): C): function (a:
IO<A>, b:
IO<B>):
IO<C>
Parameters
f (function (a: A, b: B): C)
Returns
function (a: IO<A>, b: IO<B>): IO<C>
lift3 :: (a -> b -> c -> d) -> IO a -> IO b -> IO c -> IO d
Takes an ternary function an returns an equivalent ternary function which operates on IO
values
lift3(f: function (a: A, b: B, c: C): D): function (a:
IO<A>, b:
IO<B>, c:
IO<C>):
IO<D>
Parameters
f (function (a: A, b: B, c: C): D)
Returns
function (a: IO<A>, b: IO<B>, c: IO<C>): IO<D>
Instance Members
map :: IO a ~> (a -> b) -> IO b
Transforms the result of the IO
instance
map(transform: function (a: A): B):
IO<B>
Parameters
transform (function (a: A): B)
Returns
IO<B>
andThen :: IO a ~> (a -> IO b) -> IO b
Chains the result of the IO
instance with another IO
-producing function
andThen(next: function (a: A):
IO<B>):
IO<B>
Parameters
next (function (a: A): IO<B>)
Returns
IO<B>
Maybe
The Maybe
monad
Represents the possibility of the presence or absence of a value.
Commonly used to safely deal with nullable values because it is
composable and forces the developer to explicitly handle the null case.
new Maybe()
Example
let some = Maybe.Just(42);
let none = Maybe.Nothing;
let ma = Maybe.of('foo'),
mb = Maybe.of(null);
Static Members
of :: a -> Maybe a
Returns Maybe.Just
of the given value if it is not null and Maybe.Nothing
otherwise
Parameters
Returns
Maybe<A>
Just :: a -> Maybe a
Returns a a Maybe
instance containing the given value
Parameters
Returns
Maybe<A>
Nothing :: Maybe a
A Maybe
instance which is absent of a value
Nothing
fromThrowable :: (() -> a) -> Maybe a
Takes a function which may throw an exception, and
returns either Maybe.Just
the value returned,
or Maybe.Nothing
if an exception is thrown.
fromThrowable(throwFn: function (): A):
Maybe<A>
Parameters
Returns
Maybe<A>
lift :: (a -> b) -> Maybe a -> Maybe b
Takes an unary function and returns an equivalent unary function which operates on Maybe
values
lift(f: function (a: A): B): function (a:
Maybe<A>):
Maybe<B>
Parameters
Returns
function (a: Maybe<A>): Maybe<B>
lift2 :: (a -> b -> c) -> (Maybe a -> Maybe b) -> Maybe c
Takes an binary function and returns an equivalent binary function which operates on Maybe
values
lift2(f: function (a: A, b: B): C): function (a:
Maybe<A>, b:
Maybe<B>):
Maybe<C>
Parameters
f (function (a: A, b: B): C)
Returns
function (a: Maybe<A>, b: Maybe<B>): Maybe<C>
lift3 :: (a -> b -> c -> d) -> (Maybe a -> Maybe b -> Maybe c) -> Maybe d
Takes an ternary function and returns an equivalent ternary function which operates on Maybe
values
lift3(f: function (a: A, b: B, c: C): D): function (a:
Maybe<A>, b:
Maybe<B>, c:
Maybe<C>):
Maybe<D>
Parameters
f (function (a: A, b: B, c: C): D)
Returns
function (a: Maybe<A>, b: Maybe<B>, c: Maybe<C>): Maybe<D>
Instance Members
cases :: { Just: a -> b, Nothing: () -> b } -> b
Performs a match against the possible Maybe
cases
and returns a value by executing the appropriate function
cases(patterns: {Just: function (a: A): B, Nothing: function (): B}): B
Parameters
patterns ({Just: function (a: A): B, Nothing: function (): B})
Returns
B
isJust :: Maybe a ~> () -> Bool
Returns true
if the Maybe
instance contains a value
Returns
boolean
isNothing :: Maybe a ~> () -> Bool
Returns true
if the Maybe
instance is absent of value
Returns
boolean
getOrElse :: Maybe a ~> a -> a
Returns the contained value if Just
,
otherwise returns the given default value.
getOrElse(defaultVal: A): A
Parameters
Returns
A
map :: Maybe a ~> (a -> b) -> Maybe b
If Just
, returns Just
the value transformed by
the given function, otherwise returns Nothing
map(f: function (a: A): B):
Maybe<B>
Parameters
Returns
Maybe<B>
andThen :: Maybe a ~> (a -> Maybe b) -> Maybe b
If Just
, returns the Maybe
instance resulting from passing the
contained value into the given function, otherwise returns Nothing
andThen(next: function (a: A):
Maybe<B>):
Maybe<B>
Parameters
next (function (a: A): Maybe<B>)
Returns
Maybe<B>
toString :: Maybe a ~> () -> string
Returns the string representation of the Maybe
instance
Returns
string
Pair
Pair functor
new Pair()
Static Members
from :: a -> b -> Pair a b
from(a: A, b: B):
Pair<A, B>
Parameters
Returns
Pair<A, B>
of :: [a, b] -> Pair a b
of(data: [A, B]):
Pair<A, B>
Parameters
Returns
Pair<A, B>
Instance Members
map :: Pair a b ~> ([a, b] -> [x, y]) -> Pair x y
map(f: function (p: [A, B]): [X, Y]):
Pair<X, Y>
Parameters
f (function (p: [A, B]): [X, Y])
Returns
Pair<X, Y>
Reader
The Reader monad
new Reader()
Static Members
of :: a -> Reader e a
Parameters
Returns
Reader<any, B>
merge2 :: Reader e a -> Reader f b -> Reader (e & f) [a, b]
Parameters
Returns
Reader<any, [A, B]>
merge3 :: Reader e a -> Reader f b -> Reader g c -> Reader (e & f & g) [a, b, c]
Parameters
Returns
Reader<any, [A, B, C]>
all :: [Reader e a] -> Reader e [a]
Parameters
Returns
Reader<F, Array<A>>
Ask :: () -> Reader e e
Returns
Reader<F, F>
Asks :: (e -> a) -> Reader e a
Asks(f: function (f: F): B):
Reader<F, B>
Parameters
Returns
Reader<F, B>
lift :: (a -> b) -> Reader e a -> Reader e b
lift(f: function (a: B): C): function (ra:
Reader<E, B>):
Reader<E, C>
Parameters
Returns
function (ra: Reader<E, B>): Reader<E, C>
lift2 :: (a -> b -> c) -> Reader e a -> Reader e b -> Reader e c
lift2(f: function (a: A, b: B): C)
Parameters
f (function (a: A, b: B): C)
lift3 :: (a -> b -> c -> d) -> Reader e a -> Reader e b -> Reader e c -> Reader e d
lift3(f: function (a: A, b: B, c: C): D): any
Parameters
f (function (a: A, b: B, c: C): D)
Returns
any
Instance Members
Constructs a new Reader instance
constructor(runReader: function (e: E): A)
Parameters
runReader (function (e: E): A)
map :: Reader e a ~> (a -> b) -> Reader e b
map(f: function (a: A): B):
Reader<E, B>
Parameters
Returns
Reader<E, B>
andThen :: Reader e a ~> (a -> Reader e b) -> Reader e b
Parameters
next (function (a: A): Reader<E, B>)
Returns
Reader<E, B>
Result
The Result
monad
Represents the possiblity of either a success value or an error value
new Result()
Example
let a = Result.Val(42),
b = Result.of(42);
let x = Result.Error('error!');
Static Members
of :: a -> Result a x
Alias of Result.Val
Parameters
Returns
Result<B, any>
Val :: a -> Result a x
Returns a Result
which succeeds with the given value
Parameters
Returns
Result<B, any>
Err :: x -> Result a x
Returns a Result
which fails with the given error value
Parameters
Returns
Result<any, Y>
fromThrowable :: (() -> a) -> Result a Error
Takes a function which may throw an exception and returns a Result
which
either succeeds with the return value or fails with the thrown exception
fromThrowable(throwFn: function (): B):
Result<B,
Error>
Parameters
Returns
Result<B, Error>
Instance Members
cases :: Result a ~> { Val: a -> b, Err: x -> b } -> b
Performs a match against the possible Result
cases and returns a value by executing the appropriate function
cases(patterns: {Val: function (a: A): B, Err: function (x: X): B}): B
Parameters
patterns ({Val: function (a: A): B, Err: function (x: X): B})
Returns
B
map :: Result a x ~> (a -> b) -> Result b x
map(f: function (a: A): B):
Result<B, X>
Parameters
Returns
Result<B, X>
andThen :: Result a x ~> (a -> Result b x) -> Result b x
Chains the success value of the Result
instance
with another Result
-producing function
Parameters
next (function (a: A): Result<B, X>)
Returns
Result<B, X>
handleError :: Result a x ~> (x -> Result a y) -> Result a y
Chains the error value of the Result
instance
with another Result
-producing function.
handleError(handle: function (x: X):
Result<A, Y>):
Result<A, Y>
Parameters
handle (function (x: X): Result<A, Y>)
Returns
Result<A, Y>
toMaybe :: Result a x ~> Maybe a
Returns the Result
instance converted to a Maybe
Returns
Maybe<A>
State
The State monad
new State()
Static Members
join :: State s (State s a) -> State s a
Parameters
Returns
State<T, B>
of :: a -> State a a
Parameters
Returns
State<T, T>
Get :: () -> State a a
Returns
State<T, T>
Put :: s -> State s a
Parameters
Returns
State<T, any>
Modify :: (s -> s) -> State s a
Modify(f: function (s: T): T):
State<T, any>
Parameters
Returns
State<T, any>
Instance Members
getState :: State s a ~> s -> s
getState(initState: S): S
Parameters
Returns
S
getValue :: State s a -> s -> a
getValue(initState: S): A
Parameters
Returns
A
map :: State s a -> (a -> b) -> State s b
map(f: function (a: A): B):
State<S, B>
Parameters
Returns
State<S, B>
andThen :: State s a ~> (a -> State s b) -> State s b
andThen(next: function (a: A):
State<S, B>):
State<S, B>
Parameters
next (function (a: A): State<S, B>)
Returns
State<S, B>
Task
The Task monad
new Task()
Static Members
of :: a -> Task a x
Parameters
Returns
Task<B, any>
Success :: a -> Task a x
Returns a Task that always succeeds with the given value
Success(a: B):
Task<B, any>
Parameters
Returns
Task<B, any>
Fail :: x -> Task a x
Returns a Task that always fails with the given value
Parameters
Returns
Task<any, Y>
fromResult :: Result a x -> Task a x
Parameters
Returns
Task<B, Y>
fromIO :: IO a -> Task a x
fromIO(io:
IO<B>):
Task<B, any>
Parameters
Returns
Task<B, any>
fromPromise :: Promise a -> Task a Error
Converts a promise to a task
Parameters
Returns
Task<A, Error>
▸
fromPromiseFunc(promiseFn)
fromPromiseFunc :: (() -> Promise a) -> Task a Error
Parameters
promiseFn (function (): Promise<A>)
Returns
Task<A, Error>
fromCallback :: (x -> a -> ()) -> Task a x
fromCallback(fn: function (cb: function (e: Y, v: B): void): void):
Task<B, Y>
Parameters
fn (function (cb: function (e: Y, v: B): void): void)
Returns
Task<B, Y>
fromThrowable :: (() -> a) -> Task a Error
fromThrowable(fn: function (): A):
Task<A,
Error>
Parameters
Returns
Task<A, Error>
lift :: (a -> b) -> Task a x -> Task b x
lift(f: function (t: T): U): function (tt:
Task<T, X>):
Task<U, X>
Parameters
Returns
function (tt: Task<T, X>): Task<U, X>
lift2 :: (a -> b -> c) -> Task a x -> Task b x -> Task c x
lift2(f: function (t: T, u: U): V): any
Parameters
f (function (t: T, u: U): V)
Returns
any
lift3 :: (a -> b -> c -> d) -> Task a x -> Task b x -> Task c x -> Task d x
lift3(f: function (a: A, b: B, c: C): D): any
Parameters
f (function (a: A, b: B, c: C): D)
Returns
any
Instance Members
Constructs a new Task instance
constructor(runTask: TaskExecutor<A, X>)
Parameters
runTask (TaskExecutor<A, X>)
map :: Task a x ~> (a -> b) -> Task b x
Transforms the result of this task if successful
map(f: function (a: A): B):
Task<B, X>
Parameters
Returns
Task<B, X>
andThen :: Task a x ~> (a -> Task b x) -> Task b x
Passes the result of this task into another task-producing
function if successful
andThen(next: function (a: A):
Task<B, X>):
Task<B, X>
Parameters
next (function (a: A): Task<B, X>)
Returns
Task<B, X>
handleError :: Task a x ~> (x -> Task a x) -> Task a x
Handles a failed task result
handleError(handle: function (x: X):
Task<A, any>):
Task<A, any>
Parameters
handle (function (x: X): Task<A, any>)
Returns
Task<A, any>
toMaybe :: Task a x ~> Task (Maybe a) x
Returns
Task<Maybe<A>, any>
Writer
The Writer monad
new Writer()
Static Members
of :: a -> Writer a a
Parameters
Returns
Writer<any, B>
Tell ::
Parameters
Returns
Writer<F, any>
Instance Members
runWriter :: Writer e a -> () -> [e[], a]
runWriter(): [
Array<E>, A]
Returns
[Array<E>, A]
getEnv :: Writer e a ~> e[]
Returns
Array<E>
getValue :: Writer e a -> a
getValue(): A
Returns
A
map :: Writer e a ~> (a -> b) -> Writer e b
map(f: function (a: A): B):
Writer<E, B>
Parameters
Returns
Writer<E, B>
andThen :: Write e a ~> (a -> Writer e b) -> Writer e b
Parameters
next (function (a: A): Writer<E, B>)
Returns
Writer<E, B>