cps

package cps

Members list

Packages

package cps.compat
package cps.macros
package cps.monads
package cps.plugin
package cps.runtime
package cps.stream
package cps.syntax

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
Source
AsyncShift.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object FutureCMAsyncShift.type
object BoundaryAsyncShift.type
class EitherAsyncShift[A, B]
class TryAsyncShift[T]
object TryModuleAsyncShift.type
object UsingAsyncShift.type
class Function1AsyncShift[T, R]
class IterableAsyncShift[A, CA]
class IterableOpsAsyncShift[A, C, CA]
class ListAsyncShift[A]
class MapOpsAsyncShift[K, V, CC, CI, CKV]
class SeqAsyncShift[A, C, CA]
class IndexedSeqAsyncShift[A, C, CA]
class RangeAsyncShift[R]
class OptionAsyncShift[T]
Show all

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
Source
AsyncShift.scala
Supertypes
class Object
trait Matchable
class Any
Show all
Self type
AsyncShift.type

Attributes

Source
AsyncShift.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Source
AsyncShift.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Source
AsyncShift.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object AsyncShift.type
trait CpsAsyncEffectMonad[F[_]] extends CpsAsyncMonad[F], CpsEffectMonad[F]

Async Effect Monad

Async Effect Monad

Attributes

Source
CpsMonad.scala
Supertypes
trait CpsEffectMonad[F]
trait CpsAsyncMonad[F]
trait CpsTryMonad[F]
trait CpsTrySupport[F]
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Source
CpsMonadContext.scala
Supertypes
trait CpsEffectMonad[F]
trait CpsAsyncMonad[F]
trait CpsTryMonad[F]
trait CpsTrySupport[F]
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
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
Source
CpsMonad.scala
Supertypes
trait CpsTryMonad[F]
trait CpsTrySupport[F]
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
Known subtypes
object CpsAsyncMonad

Attributes

Companion
trait
Source
CpsMonad.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Source
CpsMonadContext.scala
Supertypes
trait CpsAsyncMonad[F]
trait CpsTryMonad[F]
trait CpsTrySupport[F]
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Source
CpsMonadContext.scala
Supertypes
trait CpsTryContextMonad[F, Ctx]
trait CpsContextMonad[F, Ctx]
trait CpsAsyncMonad[F]
trait CpsTryMonad[F]
trait CpsTrySupport[F]
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all

Marker trait for concurrent effect monads.

Marker trait for concurrent effect monads.

Attributes

Source
CpsMonad.scala
Supertypes
trait CpsEffectMonad[F]
trait CpsAsyncMonad[F]
trait CpsTryMonad[F]
trait CpsTrySupport[F]
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
Known subtypes
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
Source
CpsMonad.scala
Supertypes
trait CpsAsyncMonad[F]
trait CpsTryMonad[F]
trait CpsTrySupport[F]
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Companion
trait
Source
CpsMonad.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Source
CpsMonadContext.scala
Supertypes
trait CpsMonadContext[F]
class Object
trait Matchable
class Any
Show all

Attributes

Source
CpsMonadContext.scala
Supertypes
trait CpsAsyncMonad[F]
trait CpsTryMonad[F]
trait CpsTrySupport[F]
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
Known subtypes
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

Source
CpsMonadContext.scala
Supertypes
trait CpsMonad[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

Source
CpsMonad.scala
Supertypes
trait CpsMonad[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

Source
CpsRuntimeAwait.scala
Supertypes
trait CpsRuntimeAwait[F]
class Object
trait Matchable
class Any
trait CpsMonad[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
Source
CpsMonad.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object CpsMonad

Attributes

Companion
trait
Source
CpsMonad.scala
Supertypes
class Object
trait Matchable
class Any
Self type
CpsMonad.type
trait CpsMonadContext[F[_]]

Base for context operations inside monad

Base for context operations inside monad

Attributes

Companion
object
Source
CpsMonadContext.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
trait
Source
CpsMonadContext.scala
Supertypes
class Object
trait Matchable
class Any
Self type
trait CpsMonadContextInclusion[F[_], G[_]]

Typeclass for inclusion of one monad context into another. If this inclusion exists, that we can call direct context encoding method over G[_] in F[_].

Typeclass for inclusion of one monad context into another. If this inclusion exists, that we can call direct context encoding method over G[_] in F[_].

Attributes

Companion
object
Source
CpsMonadContextInclusion.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Source
CpsMonadContextInclusion.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Source
CpsMonadContextProvider.scala
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
Companion
object
Source
CpsMonadConversion.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Source
CpsMonadConversion.scala
Supertypes
class Object
trait Matchable
class Any
Self type
sealed trait CpsMonadMemoization[F[_]]

How this monad can be memoized.

How this monad can be memoized.

see chapter in User Guide

Attributes

Companion
object
Source
CpsMonadMemoization.scala
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
Source
CpsMonadMemoization.scala
Supertypes
class Object
trait Matchable
class Any
Self type
trait CpsPureMonadInstanceContext[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 and not support try/catch operations.

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 and not support try/catch operations.

Attributes

Source
CpsMonadContext.scala
Supertypes
trait CpsMonad[F]
class Object
trait Matchable
class Any

Attributes

Source
CpsMonadContext.scala
Supertypes
trait CpsMonadContext[F]
class Object
trait Matchable
class Any
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

Source
CpsRuntimeAwait.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Indirect constructor for CpsRuntimeAwait[F] instance, which can be used in situation where runtime await instance can be build only inside of monad. (Example - cats.effect.IO)

Indirect constructor for CpsRuntimeAwait[F] instance, which can be used in situation where runtime await instance can be build only inside of monad. (Example - cats.effect.IO)

When this typeclass is implemented for a monad F, we also can process arguments of high-order functions wihout requiring of shifted variants.

Attributes

Source
CpsRuntimeAwait.scala
Supertypes
class Object
trait Matchable
class Any
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
Source
CpsMonad.scala
Supertypes
trait CpsAsyncMonad[F]
trait CpsTryMonad[F]
trait CpsTrySupport[F]
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Companion
trait
Source
CpsMonad.scala
Supertypes
class Object
trait Matchable
class Any
Self type
trait CpsThrowMonad[F[_]] extends CpsMonad[F], CpsThrowSupport[F]

Monad, where we can throw error but can catch one only outside of a monad context.

Monad, where we can throw error but can catch one only outside of a monad context.

An example as monad which interpret in sync context, such as Option or collections.

Attributes

Source
CpsMonad.scala
Supertypes
trait CpsThrowSupport[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Known subtypes
trait CpsThrowMonadContext[F[_]] extends CpsMonadContext[F]

Attributes

Source
CpsMonadContext.scala
Supertypes
trait CpsMonadContext[F]
class Object
trait Matchable
class Any
Known subtypes

Minimal monad context, which provides an instance of CpsThrowMonad. Use it if your monad supports throw operation but not try/catch.

Minimal monad context, which provides an instance of CpsThrowMonad. Use it if your monad supports throw operation but not try/catch.

Attributes

Source
CpsMonadContext.scala
Supertypes
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
Known subtypes
class IterableCpsMonad[C]

Attributes

Source
CpsMonadContext.scala
Supertypes
trait CpsMonadContext[F]
class Object
trait Matchable
class Any
trait CpsThrowSupport[F[_]]

Throw support for monads, decoupled from monad itself.

Throw support for monads, decoupled from monad itself.

Attributes

Source
CpsMonad.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait CpsTryContextMonad[F[_], Ctx <: CpsTryMonadContext[F]] extends CpsContextMonad[F, Ctx], CpsTryMonad[F]

Attributes

Source
CpsMonadContext.scala
Supertypes
trait CpsTryMonad[F]
trait CpsTrySupport[F]
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CpsContextMonad[F, Ctx]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
Known subtypes
trait CpsTryMonad[F[_]] extends CpsThrowMonad[F], CpsTrySupport[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
Source
CpsMonad.scala
Supertypes
trait CpsTrySupport[F]
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
Known subtypes
object CpsTryMonad

Attributes

Companion
trait
Source
CpsMonad.scala
Supertypes
class Object
trait Matchable
class Any
Self type
trait CpsTryMonadContext[F[_]] extends CpsThrowMonadContext[F]

Attributes

Source
CpsMonadContext.scala
Supertypes
trait CpsMonadContext[F]
class Object
trait Matchable
class Any
Known subtypes
trait CpsTryMonadInstanceContext[F[_]] extends CpsTryMonad[F]

Minimal monad context, which provides an instance of CpsTryMonad. Use it if your monad supports throw and try/catch operations.

Minimal monad context, which provides an instance of CpsTryMonad. Use it if your monad supports throw and try/catch operations.

Attributes

Source
CpsMonadContext.scala
Supertypes
trait CpsTryMonad[F]
trait CpsTrySupport[F]
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Source
CpsMonadContext.scala
Supertypes
trait CpsMonadContext[F]
class Object
trait Matchable
class Any
Show all
object ValueDiscard

Attributes

Companion
trait
Source
ValueDiscard.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Deprecated classlikes

@Deprecated("use non-wrapped direct values in CpsDirect context and -Wwarn-value-discard compiler option instead")
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

Deprecated
true
Source
ValueDiscard.scala
Supertypes
trait ValueDiscard[F[T]]
class Object
trait Matchable
class Any

Attributes

Deprecated
true
Source
CpsMonadContext.scala
Supertypes
trait CpsTryMonad[F]
trait CpsTrySupport[F]
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
@Deprecated("use non-wrapped direct values in CpsDirect context and -Wwarn-value-discard compiler option instead")
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
Deprecated
true
Source
ValueDiscard.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class AwaitValueDiscard[F, T]
@Deprecated("Use context direct functions and -Wwarn-value-discard compiler option instead")
object customValueDiscard extends CustomTag

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

Deprecated
true
Source
ValueDiscard.scala
Supertypes
class CustomTag
class Object
trait Matchable
class Any
Self type
@Deprecated("Use compiler flag -Wwarn-value-discard instead")
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

Deprecated
true
Source
ValueDiscard.scala
Supertypes
class WarnTag
class Object
trait Matchable
class Any
Self type

Experimental classlikes

opaque object CpsDirect

Attributes

Experimental
true
Source
CpsDirect.scala
Supertypes
class Object
trait Matchable
class Any
Self type
CpsDirect.type

Types

type CpsDirect[F[_]] = Direct[F]

Direct style context marker, used to mark function, whritten in direct style. When function have given parameter of type CpsDirect[F] or return context lambda with CpsDirect[F] parameter, then compiler plugin will transform function result into monadic form. For example:

Direct style context marker, used to mark function, whritten in direct style. When function have given parameter of type CpsDirect[F] or return context lambda with CpsDirect[F] parameter, then compiler plugin will transform function result into monadic form. For example:

 def fetch(url: String): CpsDirect[Future] ?=> String = ...

Attributes

Source
CpsDirect.scala

Deprecated types

Attributes

Deprecated
true
Source
CpsMonadContext.scala

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

Source
Async.scala
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

Source
AsyncStream.scala
def await[F[_], T, G[_]](f: F[T])(using ctx: CpsMonadContext[G], conversion: CpsMonadConversion[F, 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

Source
Async.scala
transparent inline def reflect[F[_], T, G[_]](f: F[T])(using inline ctx: CpsMonadContext[G], inline conv: CpsMonadConversion[F, G]): T

Synonym for await

Synonym for await

Attributes

Source
Async.scala
transparent inline def reify[F[_]](using am: CpsMonad[F]): InferAsyncArg[F, Context]

Synonym for async which can be better operation name for non-computation monads.

Synonym for async which can be better operation name for non-computation monads.

Attributes

Source
Async.scala

Experimental methods

def asynchronized[F[_], T](t: Direct[F] ?=> T)(using ctx: Direct[F]): F[T]

Pseudofunction, which can be used inside async block or in function with CpsDirect[F] context parameter, to 'asynchronize computation' (i.e. receive value of F[T] from t:FT). The main usage is in direct mode, where all computations are 'awaited' by default. Inside async block can be viewed as empty wrapper.

Pseudofunction, which can be used inside async block or in function with CpsDirect[F] context parameter, to 'asynchronize computation' (i.e. receive value of F[T] from t:FT). The main usage is in direct mode, where all computations are 'awaited' by default. Inside async block can be viewed as empty wrapper.

Type parameters

F
  • monad
T
  • type of expression

Value parameters

ctx
  • Monad context
t
  • expression in direct mode

Attributes

Returns
  • t expression represented in monadic form
Todo
  • currently attempt to makr t context-dependend(i.e. pss to asynchronized t: CpsMonadContext[F] ?=>T) leads to error during typing. Need to investigate and submit bug to dotty.
Experimental
true
Source
Async.scala
transparent inline def reifed[F[_], T](t: Direct[F] ?=> T)(using inline ctx: Direct[F]): F[T]

Attributes

Experimental
true
Source
Async.scala

Givens

Deprecated givens

@Deprecated("Use context direct functions and -Wwarn-value-discard compiler option instead")

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

Deprecated
true
Source
ValueDiscard.scala
@Deprecated("Use compiler flag -Wwarn-value-discard instead")

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

Deprecated
true
Source
ValueDiscard.scala