cps

package cps

Members list

Concise view

Type members

Classlikes

trait AsyncShift[T]

AsynsShift is a marker base trait for typeclass, which provides 'shifted' variants of the hight-order methods of T, which called when we need to pass a cps-transformed function as an argument for this method.

AsynsShift is a marker base trait for typeclass, which provides 'shifted' variants of the hight-order methods of T, which called when we need to pass a cps-transformed function as an argument for this method.

The general convention is next:

  • Let us have object O and method m(f: A=>B):R which accept hight-order argument f: A=>B. (for example - map in List).
  • If we want to defined transformation of argument for any monad F, we should define the AsyncShift[O] with method m[F[_],...](o:O, m:CpsMonad[F])(f: A=>F[B]).
  • Return type of this method can be F[R] or R or AsyncSubst[R].

Also we should define a given instance of AsyncShift[O], visible from our async block. I.e. implementation for our list will look as:

   class MyShiftedList[T] extentds AsyncShift[List[T]] {

     def map[F[_],S](m:CpsMonad[M], c:List[T])(f: T=>F[S]): F[List[T]] =
         ... // implementation here

   }

   transparent inline given myShiftedList[T]: AsyncShift[List[T]] = MyShiftedList[T]()

After this, you can freely use awaits inside "List.map":

  async {
    ....
    val fetched = uris.map(uri => await(fetch(uri)))
    ...
  }

see https://rssh.github.io/dotty-cps-async/HighOrderFunctions.html

Attributes

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class IterableAsyncShift[A, CA]
class IterableOpsAsyncShift[A, C, CA]
class MapOpsAsyncShift[K, V, CC, CI, CKV]
class SeqAsyncShift[A, C, CA]
class IndexedSeqAsyncShift[A, C, CA]
class EitherAsyncShift[A, B]
class TryAsyncShift[T]
object UsingAsyncShift.type
object AsyncShift

Companion object where defined given AsyncShift instances for Scala standard library objects.

Companion object where defined given AsyncShift instances for Scala standard library objects.

Attributes

See also:

[cps.AsyncShift]

Companion:
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
class AwaitValueDiscard[F[_], T] extends ValueDiscard[F[T]]

Marker interface for forcing monad evaluation before discard. Useful for pure effect monads. AwaitValueDiscard[F,T].apply(ft) is transformed to await(ft) during evaluation of async macro.

Marker interface for forcing monad evaluation before discard. Useful for pure effect monads. AwaitValueDiscard[F,T].apply(ft) is transformed to await(ft) during evaluation of async macro.

Attributes

Graph
Supertypes
trait ValueDiscard[F[T]]
class Object
trait Matchable
class Any
trait CpsAsyncEffectMonad[F[_]] extends CpsAsyncMonad[F] with CpsEffectMonad[F]

Async Effect Monad

Async Effect Monad

Attributes

Graph
Supertypes
trait CpsAsyncMonad[F]
trait CpsTryMonad[F]
trait CpsMonad[F]
trait CpsAwaitable[F]
class Object
trait Matchable
class Any
Known subtypes
trait CpsAsyncMonad[F[_]] extends CpsTryMonad[F]

Monad, which is compatible with passing data via callbacks.

Monad, which is compatible with passing data via callbacks.

Interoperability with Future: allows

   async[F]{ .. await[Future](..) ... }

Attributes

Companion:
object
Graph
Supertypes
trait CpsTryMonad[F]
trait CpsMonad[F]
trait CpsAwaitable[F]
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion:
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
trait CpsAwaitable[F[_]]

Marker typeclass for wrappers, which we can await. Such traits can be not monads itself (for example, its impossible to set monad structure over js.Promise) but can be convertable into cps monads.

Marker typeclass for wrappers, which we can await. Such traits can be not monads itself (for example, its impossible to set monad structure over js.Promise) but can be convertable into cps monads.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait CpsConcurrentContextMonad[F[_], Ctx <: CpsMonadContext[F]] extends CpsConcurrentMonad[F] with CpsContextMonad[F, Ctx]

Attributes

Graph
Supertypes
trait CpsContextMonad[F, Ctx]
trait CpsAsyncMonad[F]
trait CpsTryMonad[F]
trait CpsMonad[F]
trait CpsAwaitable[F]
class Object
trait Matchable
class Any

Marker trait for concurrent effect monads.

Marker trait for concurrent effect monads.

Attributes

Graph
Supertypes
trait CpsAsyncMonad[F]
trait CpsTryMonad[F]
trait CpsMonad[F]
trait CpsAwaitable[F]
class Object
trait Matchable
class Any
trait CpsConcurrentMonad[F[_]] extends CpsAsyncMonad[F]

Monad, where we can define an effect of starting operation in different execution flow.

Monad, where we can define an effect of starting operation in different execution flow.

Attributes

Companion:
object
Graph
Supertypes
trait CpsAsyncMonad[F]
trait CpsTryMonad[F]
trait CpsMonad[F]
trait CpsAwaitable[F]
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion:
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
trait CpsContextMonad[F[_], Ctx <: CpsMonadContext[F]] extends CpsMonad[F]

Base trait of CpsContextMonad which provide Ctx as a monad context Mixin this trait into your CosMonad in cases, when you monad have internal API and you potentially want to use moand context as generic type.

Base trait of CpsContextMonad which provide Ctx as a monad context Mixin this trait into your CosMonad in cases, when you monad have internal API and you potentially want to use moand context as generic type.

Attributes

Graph
Supertypes
trait CpsMonad[F]
trait CpsAwaitable[F]
class Object
trait Matchable
class Any
Known subtypes
trait CpsEffectMonad[F[_]] extends CpsMonad[F]

Marker trait, which mark effect monad, where actual evaluation of expression happens after building a monad, during effect evaluation stage.

Marker trait, which mark effect monad, where actual evaluation of expression happens after building a monad, during effect evaluation stage.

evaluation of expression inside async block always delayed.

Attributes

Graph
Supertypes
trait CpsMonad[F]
trait CpsAwaitable[F]
class Object
trait Matchable
class Any
Known subtypes
trait CpsFastRuntimeAwait[F[_]] extends CpsRuntimeAwait[F]

Marker class which mean that CpsRuntimeAwait implemented in such way, that performance penalty in comparison with cps run is relative low and we can not to use cps transformation in async block for such monad.

Marker class which mean that CpsRuntimeAwait implemented in such way, that performance penalty in comparison with cps run is relative low and we can not to use cps transformation in async block for such monad.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
trait CpsMonad[F[_]] extends CpsAwaitable[F]

Basic CpsMonad operations. Implementing this typeclass is enough to use async/await with supports of basic control-flow constructions (if, loops, but no exceptions).

Basic CpsMonad operations. Implementing this typeclass is enough to use async/await with supports of basic control-flow constructions (if, loops, but no exceptions).

Attributes

Companion:
object
Graph
Supertypes
trait CpsAwaitable[F]
class Object
trait Matchable
class Any
Known subtypes
object CpsMonad

Attributes

Companion:
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
trait CpsMonadContext[F[_]]

Base for context operations inside monad

Base for context operations inside monad

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
trait CpsMonadConversion[F[_], G[_]]

CpsMonadConversion -- conversion from F[_] to G[_]. If the given instance of such morphism exists, then await[F] can be used inside async[G]

CpsMonadConversion -- conversion from F[_] to G[_]. If the given instance of such morphism exists, then await[F] can be used inside async[G]

Attributes

See also:
Graph
Supertypes
class Object
trait Matchable
class Any
trait CpsMonadInstanceContext[F[_]] extends CpsMonad[F]

Trait for minimal monad context, which provides an instance of CpsMonad. Mixin this trait into your monad in cases, when you monad have no internal API.

Trait for minimal monad context, which provides an instance of CpsMonad. Mixin this trait into your monad in cases, when you monad have no internal API.

Attributes

Graph
Supertypes
trait CpsMonad[F]
trait CpsAwaitable[F]
class Object
trait Matchable
class Any
Known subtypes
object FreeCpsMonad.type

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
sealed trait CpsMonadMemoization[F[_]]

How this monad can be memoized.

How this monad can be memoized.

see chapter in User Guide

Attributes

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Dynamic[F]
trait Inplace[F]
class Default[F]
object futureMemoization.type
trait Pure[F]

Attributes

Companion:
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

marker trait for context with NOOP intercaprAwait operation

marker trait for context with NOOP intercaprAwait operation

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait CpsRuntimeAwait[F[_]]

When this typeclass is implemented for a monad F, dotty-cps-async can use runtime await invocations for handling of high-order functions when shifted variants are not available.

When this typeclass is implemented for a monad F, dotty-cps-async can use runtime await invocations for handling of high-order functions when shifted variants are not available.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait CpsSchedulingMonad[F[_]] extends CpsConcurrentMonad[F]

Monad, where we can spawn some event and be sure that one be evaluated, event if we drop result.

Monad, where we can spawn some event and be sure that one be evaluated, event if we drop result.

Interoperability with Future: allows

  async[Future]{
     ...
     await[F](..)
     ...
  }

Attributes

Companion:
object
Graph
Supertypes
trait CpsAsyncMonad[F]
trait CpsTryMonad[F]
trait CpsMonad[F]
trait CpsAwaitable[F]
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion:
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
trait CpsTryMonad[F[_]] extends CpsMonad[F]

If you monad supports this typeclass, than you can use try/catch/finally inside await.

If you monad supports this typeclass, than you can use try/catch/finally inside await.

Attributes

Companion:
object
Graph
Supertypes
trait CpsMonad[F]
trait CpsAwaitable[F]
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion:
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
trait ValueDiscard[T]

When cps.customValueDiscard is on, value can be discarded only for types T for which exists ValueDiscard[T]

When cps.customValueDiscard is on, value can be discarded only for types T for which exists ValueDiscard[T]

see chapter in User Guide

Attributes

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion:
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

marker object for value discarding. When this object is imported into current scope, then discarding values inside async block is translated to summon[ValueDiscard[T]].apply()

marker object for value discarding. When this object is imported into current scope, then discarding values inside async block is translated to summon[ValueDiscard[T]].apply()

Attributes

Graph
Supertypes
class CustomTag
class Object
trait Matchable
class Any
Self type
object warnValueDiscard extends WarnTag

marker object for enabling warning about discarding non-primitve values without custom discard.

marker object for enabling warning about discarding non-primitve values without custom discard.

Attributes

Graph
Supertypes
class WarnTag
class Object
trait Matchable
class Any
Self type

Value members

Concrete methods

transparent inline def async[F[_]](using am: CpsMonad[F]): InferAsyncArg[F, Context]

async block, which can contains awaits. better look on this as the first part of the next signature:

async block, which can contains awaits. better look on this as the first part of the next signature:

  async[F](using CpsMonad[F])[T](inline body:T):F[T]

i.e. async return a transitional object, which accepts body and perform async transform with the given CpsMonad[F].

Attributes

transparent inline def asyncStream[R](using a: CpsAsyncEmitAbsorber[R]): AsyncStreamHelper[R, Monad, Context, Element]

Generator syntax. usage:

Generator syntax. usage:

val s = asyncStream[fs.Stream[IO,Int]] { out =>
  for(i <- 1 to N) out.emit(i)
}

Attributes

def await[F[_], T, G[_]](f: F[T])(using am: CpsAwaitable[F], ctx: CpsMonadContext[G]): T

Pseudofunction, which can be used inside async block, to 'await' (i.e. receive value of t:T from ft:F[T]).

Pseudofunction, which can be used inside async block, to 'await' (i.e. receive value of t:T from ft:F[T]).

Attributes

Givens

Givens

marker object for value discarding. When this object is imported into current scope, then discarding values inside async block is translated to summon[ValueDiscard[T]].apply()

marker object for value discarding. When this object is imported into current scope, then discarding values inside async block is translated to summon[ValueDiscard[T]].apply()

Attributes

marker object for enabling warning about discarding non-primitve values without custom discard.

marker object for enabling warning about discarding non-primitve values without custom discard.

Attributes