trait Raise[F[_], -E] extends Serializable
Raise[F, E]
expresses the ability to raise errors of type E
in a functorial F[_]
context.
This means that a value of type F[A]
may contain no A
values but instead an E
error value,
and further map
calls will not have any values to execute the passed function on.
Raise
has no external laws.
Raise
has two internal laws:
def catchNonFatalDefault[A](a: => A)(f: Throwable => E)(implicit A: Applicative[F]) = { catchNonFatal(a)(f) <-> try { A.pure(a) } catch { case NonFatal(ex) => raise(f(ex)) } } def ensureDefault[A](fa: F[A])(error: => E)(predicate: A => Boolean)(implicit A: Monad[F]) = { ensure(fa)(error)(predicate) <-> for { a <- fa _ <- if (predicate(a)) pure(()) else raise(error) } yield a }
Raise
has one free law, i.e. a law guaranteed by parametricity:
def failThenFlatMapFails[A, B](ex: E, f: A => F[B]) = { fail(ex).flatMap(f) <-> fail(ex) } guaranteed by: fail[X](ex) <-> fail[F[Y]](ex) // parametricity fail[X](ex).map(f) <-> fail[F[Y]](ex) // map must have no effect, because there's no X value fail[X](ex).map(f).join <-> fail[F[Y]].join // add join to both sides fail(ex).flatMap(f) <-> fail(ex) // join is equal, because there's no inner value to flatten effects from // QED.
- Annotations
- @implicitNotFound("Could not find an implicit instance of Raise[${F}, ${E}]. If you have\na good way of handling errors of type ${E} at this location, you may want\nto construct a value of type EitherT for this call-site, rather than ${F}.\nAn example type:\n\n EitherT[${F}, ${E}, *]\n\nThis is analogous to writing try/catch around this call. The EitherT will\n\"catch\" the errors of type ${E}.\n\nIf you do not wish to handle errors of type ${E} at this location, you should\nadd an implicit parameter of this type to your function. For example:\n\n (implicit fraise: Raise[${F}, ${E}])\n")
- Source
- Raise.scala
Linear Supertypes
Known Subclasses
Type Hierarchy
Ordering
- Alphabetic
- By Inheritance
Inherited
- Raise
- Serializable
- AnyRef
- Any
- Hide All
- Show All
Visibility
- Public
- Protected
Abstract Value Members
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def catchNonFatal[E2 <: E, A](a: => A)(f: (Throwable) => E2)(implicit A: Applicative[F]): F[A]
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def ensure[E2 <: E, A](fa: F[A])(error: => E2)(predicate: (A) => Boolean)(implicit A: Monad[F]): F[A]
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()