root

cps-async-connect: integration of dotty-cps-async with effect stacks

License

License

GroupId

GroupId

com.github.rssh
ArtifactId

ArtifactId

root_2.12
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

root
cps-async-connect: integration of dotty-cps-async with effect stacks
Project URL

Project URL

https://github.com/rssh/cps-async-connect
Project Organization

Project Organization

rssh
Source Code Management

Source Code Management

https://github.com/rssh/cps-async-connect

Download root_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.rssh/root_2.12/ -->
<dependency>
    <groupId>com.github.rssh</groupId>
    <artifactId>root_2.12</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.rssh/root_2.12/
implementation 'com.github.rssh:root_2.12:0.2.0'
// https://jarcasting.com/artifacts/com.github.rssh/root_2.12/
implementation ("com.github.rssh:root_2.12:0.2.0")
'com.github.rssh:root_2.12:jar:0.2.0'
<dependency org="com.github.rssh" name="root_2.12" rev="0.2.0">
  <artifact name="root_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.rssh', module='root_2.12', version='0.2.0')
)
libraryDependencies += "com.github.rssh" % "root_2.12" % "0.2.0"
[com.github.rssh/root_2.12 "0.2.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.12

Project Modules

There are no modules declared in this project.

This is a helper connect objects for providing dotty-cps-async CpsAsyncMonad typeclasses for common effect stacks.

cats-effects:

  libraryDependencies += "com.github.rssh" %%% "cps-async-connect-cats-effect" % "0.3.0"  

Usage:

import cps._
import cps.monads.cats.given

...
def doSomething(): IO[T] = async[IO] {
   ...
}

or import specific class to allow compiler to deduce given monad automatically.

  • IO - catsIO (implements CpsAsyncMonad with conversion to Future)
  • Generic F[_]:Async - catsAsync (implements CpsAsyncMonad)
  • Generic F[_]:MonadThrow - catsMonadThrow (implements CpsTryMonad)
  • Generic F[_]:Monad - catsMonad (implements CpsMonad)

scalaz IO:

  libraryDependencies += "com.github.rssh" %%% "cps-async-connect-scalaz" % "0.3.0"  
  • IO - cps.monads.scalaz.scalazIO (implements CpsTryMonad)

zio:

  libraryDependencies += "com.github.rssh" %%% "cps-async-connect-zio" % "0.3.0"  

Usage:

import cps.*
import cps.monads.zio.{given,*}

 val program = asyncRIO[R] {
    .....
 }

or for task:

 val program = async[Task] {
   ....
 }

for ZIO with custom error E you should have given ThrowableAdapter[R,E] which will map E and Throwable in both directions.

case class MyError(...)

given ThrowableAdapter[R] with

     def toThrowable(e: MyError): Throwable = ...
        
     def fromThrowable[A](e:Throwable): ZIO[R,E,A] = ...
  • ZIO - asyncZIO[R,E] as shortcat for async[[X]=>>ZIO[R,E,X]] (implements CpsAsyncMonad with conversion to Future if we have given Runtime in scope.)
  • RIO - use asyncRIO[R] (implements CpsAsyncMonad with conversion)
  • Task - use async[Task] (implements CpsAsyncMonad with conversion)
  • URIO - use asyncURIO[R] (implements CpsMonad)

Versions

Version
0.2.0
0.1.0