Wrap a call to a deterministic partial function, making a total function.
Wrap a call to a deterministic partial function, making a total function. May be used to interface with legacy methods that do not have an FP equivalent.
The err
callback must convert the non-referentially transparent
Throwable
(which is anything caught by the NonFatal
construct) into a
data type. The caller is trusted not to allow the stack trace to escape
into the A
data type.
Note that exceptions are extremely inefficient. Callers should consider validating the input to their partial function and exiting early.
If no useful information can be obtained from the Throwable
, prefer
scalaz.Maybe#attempt.
For interfacing with non-deterministic blocks of code that may or may not
throw Throwable
, use scalaz.effect.IO.
For interfacing with deterministic functions that violate the type system
by returning null
, use scalaz.Maybe#fromNullable.
Construct a disjunction value from a standard scala.Either
.
Construct a disjunction value from a standard scala.Option
.
Construct a left disjunction value.
Spin in tail-position on the left value of the given disjunction.
Spin in tail-position on the left value of the given disjunction.
Spin in tail-position on the right value of the given disjunction.
Spin in tail-position on the right value of the given disjunction.
Construct a right disjunction value.
(Since version 7.3.0) Throwable is not referentially transparent, use \/.attempt
(Since version 7.3.0) Throwable is not referentially transparent, use \/.attempt