mirror of
https://github.com/fluencelabs/codec
synced 2025-04-24 22:32:13 +00:00
Docs for existential type bound for MonadError
This commit is contained in:
parent
e1b5bfb947
commit
6378af3658
@ -62,7 +62,8 @@ abstract class MonadicalEitherArrow[E <: Throwable] {
|
|||||||
* Run the func on input, lifting the error into MonadError effect.
|
* Run the func on input, lifting the error into MonadError effect.
|
||||||
*
|
*
|
||||||
* @param input Input
|
* @param input Input
|
||||||
* @param F All internal maps and composes, as well as errors, are to be executed with this Monad
|
* @param F All internal maps and composes, as well as errors, are to be executed with this MonadError.
|
||||||
|
* Error type should be a supertype for this arrow's error E.
|
||||||
*/
|
*/
|
||||||
def runF[F[_]](input: A)(implicit F: MonadError[F, EE] forSome {type EE >: E}): F[B] =
|
def runF[F[_]](input: A)(implicit F: MonadError[F, EE] forSome {type EE >: E}): F[B] =
|
||||||
runEither(input).flatMap(F.fromEither)
|
runEither(input).flatMap(F.fromEither)
|
||||||
@ -78,7 +79,8 @@ abstract class MonadicalEitherArrow[E <: Throwable] {
|
|||||||
/**
|
/**
|
||||||
* Converts this Func to Kleisli, using MonadError to execute upon and to lift errors into.
|
* Converts this Func to Kleisli, using MonadError to execute upon and to lift errors into.
|
||||||
*
|
*
|
||||||
* @param F All internal maps and composes, as well as errors, are to be executed with this Monad
|
* @param F All internal maps and composes, as well as errors, are to be executed with this MonadError.
|
||||||
|
* Error type should be a supertype for this arrow's error E.
|
||||||
*/
|
*/
|
||||||
def toKleisli[F[_]](implicit F: MonadError[F, EE] forSome {type EE >: E}): Kleisli[F, A, B] =
|
def toKleisli[F[_]](implicit F: MonadError[F, EE] forSome {type EE >: E}): Kleisli[F, A, B] =
|
||||||
Kleisli(input ⇒ runF[F](input))
|
Kleisli(input ⇒ runF[F](input))
|
||||||
@ -191,6 +193,15 @@ abstract class MonadicalEitherArrow[E <: Throwable] {
|
|||||||
EitherT.rightT[F, E](input).subflatMap(f)
|
EitherT.rightT[F, E](input).subflatMap(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check a condition, lifted with a Func.
|
||||||
|
*
|
||||||
|
* @param error Error to produce when condition is not met
|
||||||
|
* @return Func that takes boolean, checks it, and returns Unit or fails with given error
|
||||||
|
*/
|
||||||
|
def cond(error: ⇒ E): Func[Boolean, Unit] =
|
||||||
|
liftFuncEither(Either.cond(_, (), error))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lift a function which returns a Func arrow with Unit on the left side.
|
* Lift a function which returns a Func arrow with Unit on the left side.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user