An implicit conversion to automatically call ".run" on EitherT monads when it can be inferred that you want to unwrap the transformer.
An implicit conversion to automatically call ".run" on EitherT monads when it can be inferred that you want to unwrap the transformer.
the right-hand type of the disjunction
the EitherT monad transformer to unwrap/run
an unwrapped Future disjunction
Lift a wrapped future disjunction into an EitherT.
Lift a wrapped future disjunction into an EitherT.
Given a future list of disjunctions, lift it into an EitherT transformer that stores the first error encountered, or a list of all right-hand-side data.
Given a future list of disjunctions, lift it into an EitherT transformer that stores the first error encountered, or a list of all right-hand-side data.
Given a list of future disjunctions, lift them into an EitherT transformer that stores the first error encountered, or a list of all right-hand-side data.
Given a list of future disjunctions, lift them into an EitherT transformer that stores the first error encountered, or a list of all right-hand-side data.
Optionally call a function to return a value, depending on whether the optional parameter is defined or not.
Optionally call a function to return a value, depending on whether the optional parameter is defined or not. If it is not, instead return a default value.
the type of the optional parameter
the success type returned by f
the optional parameter
the function to call with the optional parameter
the default value to return if the optional parameter is not defined
Given a future boolean condition, and an instance of the left-hand failure type, build an EitherT transformer that contains Unit when the condition is true, or contains the failure when the condition is false.
Given a future boolean condition, and an instance of the left-hand failure type, build an EitherT transformer that contains Unit when the condition is true, or contains the failure when the condition is false. Useful for making short-circuiting assertions in for-comprehensions.
Example usage:
for { foo <- lift(fooRepository.find(fooId)) _ <- predicate (foo.name == "Bar") (FooError("Foo can't be named Bar")) // The for-comprehension only continues if the predicate's condition was true. Otherwise it // short-circuits and evaluates to the FooError. } yield foo
the boolean condition to test, wrapped in a Future
the failure to return when the condition is false
a scalaz.EitherT
Given a boolean condition, and an instance of the left-hand failure type, build an EitherT transformer that contains Unit when the condition is true, or contains the failure when the condition is false.
Given a boolean condition, and an instance of the left-hand failure type, build an EitherT transformer that contains Unit when the condition is true, or contains the failure when the condition is false. Useful for making short-circuiting assertions in for-comprehensions.
Example usage:
for { foo <- lift(fooRepository.find(fooId)) _ <- predicate (foo.name == "Bar") (FooError("Foo can't be named Bar")) // The for-comprehension only continues if the predicate's condition was true. Otherwise it // short-circuits and evaluates to the FooError. } yield foo
the boolean condition to test
the failure to return when the condition is false
a scalaz.EitherT
Given a collection, and some function to map over the collection whose result type is a future disjunction, this function runs the given function over the collection sequentially.
Given a collection, and some function to map over the collection whose result type is a future disjunction, this function runs the given function over the collection sequentially. Use this when you would have a list of Futures that cannot be run in parallel, for example if they will all run on the same database connection.
val fooList: IndexedSeq[Foo] = Vector(foo1, foo2, foo3) def barFunc(foo: Foo): Future[Bar] // The resultant list will be generated sequentially with no parallel operations val futureBarList: Future[IndexedSeq[Bar]] = serializedT(fooList)(barFunc)
Given a collection, and some function to map over the collection whose result type is a future disjunction, this function runs the given function over the collection sequentially.
Given a collection, and some function to map over the collection whose result type is a future disjunction, this function runs the given function over the collection sequentially. Use this when you would have a list of Futures that cannot be run in parallel, for example if they will all run on the same database connection.
val fooList: IndexedSeq[Foo] = Vector(foo1, foo2, foo3) def barFunc(foo: Foo): Future[\/[Error, Bar]] // The resultant list will be generated sequentially with no parallel operations val futureBarList: Future[\/[Error, IndexedSeq[Bar]] = serializedT(fooList)(barFunc)
the starting type of the elements in the list
the transformed type of the elements in the list
the exact type of list, which must be an indexed sequence
the list of objects to be mapped
the function to be applied to each element of the list
This trait provides several utility functions that can be used with Futures in conjunction with scalaz.\/ and its scalaz.EitherT monad transformer.
is the failure type to use on the left-hand side of disjunctions. NB: the left-hand type is invariant in the EitherT transformer.