trait Lifting[A] extends FutureMonad with Serialized
This trait provides several utility functions that can be used with Futures in conjunction with scalaz.\/ and its scalaz.EitherT monad transformer.
- A
is the failure type to use on the left-hand side of disjunctions. NB: the left-hand type is invariant in the EitherT transformer.
- Alphabetic
- By Inheritance
- Lifting
- Serialized
- FutureMonad
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
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
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate() @throws( ... )
-
implicit
def
eitherRunner[B](eithert: EitherT[Future, A, B]): Future[\/[A, B]]
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.
- B
the right-hand type of the disjunction
- eithert
the EitherT monad transformer to unwrap/run
- returns
an unwrapped Future disjunction
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
implicit
val
futureMonad: Monad[Future]
- Definition Classes
- FutureMonad
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
lift[B]: (Future[\/[A, B]]) ⇒ EitherT[Future, A, B]
Lift a wrapped future disjunction into an EitherT.
- implicit def liftFun[X, T, U](f: (X) ⇒ U)(implicit arg0: (T) ⇒ X): (T) ⇒ U
-
def
liftSeq[B](fIntermediate: Future[IndexedSeq[\/[A, B]]])(implicit ec: ExecutionContext): EitherT[Future, A, IndexedSeq[B]]
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.
-
def
liftSeq[B](interList: IndexedSeq[Future[\/[A, B]]])(implicit ec: ExecutionContext): EitherT[Future, A, IndexedSeq[B]]
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.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
optionally[I, B](anOption: Option[I])(f: (I) ⇒ EitherT[Future, A, B])(default: B): EitherT[Future, A, B]
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.
- I
the type of the optional parameter
- B
the success type returned by f
- anOption
the optional parameter
- f
the function to call with the optional parameter
- default
the default value to return if the optional parameter is not defined
- implicit def pipeTo[T](t: T): Pipe[T]
-
def
predicate(fCondition: Future[\/[A, Boolean]])(fail: A)(implicit ec: ExecutionContext): EitherT[Future, A, Unit]
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
- fCondition
the boolean condition to test, wrapped in a Future
- fail
the failure to return when the condition is false
- returns
a scalaz.EitherT
-
def
predicate(condition: Boolean)(fail: A): EitherT[Future, A, Unit]
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
- condition
the boolean condition to test
- fail
the failure to return when the condition is false
- returns
a scalaz.EitherT
- def readerOptional[I, C, B](anOption: Option[I])(f: (I) ⇒ ReaderTE[C, B])(default: B): ReaderTE[C, B]
-
def
serialized[E, R, L[E] <: IndexedSeq[E]](collection: L[E])(fn: (E) ⇒ Future[R])(implicit ec: ExecutionContext): Future[IndexedSeq[R]]
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)
- Definition Classes
- Serialized
-
def
serializedT[E, R, L[E] <: IndexedSeq[E]](collection: L[E])(fn: (E) ⇒ Future[\/[A, R]])(implicit ec: ExecutionContext): Future[\/[A, IndexedSeq[R]]]
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)
- E
the starting type of the elements in the list
- R
the transformed type of the elements in the list
- L
the exact type of list, which must be an indexed sequence
- collection
the list of objects to be mapped
- fn
the function to be applied to each element of the list
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
- object ReaderTE extends KleisliInstances