ca.shiftfocus.lib.concurrent

Lifting

Related Doc: package concurrent

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.

Linear Supertypes
Serialized, FutureMonad, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Lifting
  2. Serialized
  3. FutureMonad
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. 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

  7. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. implicit val futureMonad: Monad[Future]

    Definition Classes
    FutureMonad
  11. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  12. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  13. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  14. def lift[B]: (Future[\/[A, B]]) ⇒ EitherT[Future, A, B]

    Lift a wrapped future disjunction into an EitherT.

    Lift a wrapped future disjunction into an EitherT.

    B
    returns

  15. 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.

    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.

    B
    fIntermediate
    returns

  16. 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.

    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.

    B
    interList
    returns

  17. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  18. final def notify(): Unit

    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  20. def optionally[I, B](anOption: Option[I])(f: (I) ⇒ 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

    returns

  21. 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

  22. 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

  23. 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)
    E
    R
    L
    collection
    fn
    returns

    Definition Classes
    Serialized
  24. 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

    returns

  25. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  26. def toString(): String

    Definition Classes
    AnyRef → Any
  27. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serialized

Inherited from FutureMonad

Inherited from AnyRef

Inherited from Any

Ungrouped