Skip to content

Commit 13f3128

Browse files
committed
adopted to dotty-cps-async 0.9.8
1 parent 17bfcff commit 13f3128

File tree

6 files changed

+23
-16
lines changed

6 files changed

+23
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
For scala 3.1.1+:
88

9-
libraryDependencies += "com.github.rssh" %% "scala-gopher" % "3.0.1"
9+
libraryDependencies += "com.github.rssh" %% "scala-gopher" % "3.0.2"
1010

1111
For scala 3 and 3.1.0:
1212

build.sbt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//val dottyVersion = "3.0.0-RC2-bin-SNAPSHOT"
22
val dottyVersion = "3.1.1"
3+
//val dottyVersion = "3.1.3-RC1-bin-SNAPSHOT"
34
//val dottyVersion = dottyLatestNightlyBuild.get
45

56
ThisBuild/version := "3.0.2-SNAPSHOT"
@@ -10,7 +11,7 @@ val sharedSettings = Seq(
1011
scalaVersion := dottyVersion,
1112
name := "scala-gopher",
1213
resolvers += "Local Ivy Repository" at "file://"+Path.userHome.absolutePath+"/.ivy2/local",
13-
libraryDependencies += "com.github.rssh" %%% "dotty-cps-async" % "0.9.7",
14+
libraryDependencies += "com.github.rssh" %%% "dotty-cps-async" % "0.9.8",
1415
libraryDependencies += "org.scalameta" %%% "munit" % "0.7.29" % Test,
1516
)
1617

@@ -26,14 +27,14 @@ lazy val root = project
2627
).enablePlugins(GhpagesPlugin, SiteScaladocPlugin)
2728

2829

29-
30+
// for scala-native support we need munit
3031
lazy val gopher = crossProject(JSPlatform, JVMPlatform)
3132
.in(file("."))
3233
.settings(sharedSettings)
3334
.disablePlugins(SitePlugin)
3435
.disablePlugins(SitePreviewPlugin)
3536
.jvmSettings(
36-
scalacOptions ++= Seq( "-unchecked", "-Ycheck:macros", "-uniqid", "-Xprint:types" ),
37+
scalacOptions ++= Seq( "-unchecked", "-Ycheck:macros", "-uniqid", "-Xprint:types", "-explain" ),
3738
fork := true,
3839
/*
3940
javaOptions ++= Seq(
@@ -45,7 +46,7 @@ lazy val gopher = crossProject(JSPlatform, JVMPlatform)
4546
Compile / doc / scalacOptions := Seq("-groups",
4647
"-source-links:shared=github://rssh/scala-gopher/master#shared",
4748
"-source-links:jvm=github://rssh/scala-gopher/master#jvm"),
48-
mimaPreviousArtifacts := Set( "com.github.rssh" %% "scala-gopher" % "3.0.0" )
49+
mimaPreviousArtifacts := Set( "com.github.rssh" %% "scala-gopher" % "3.0.1" )
4950
).jsSettings(
5051
libraryDependencies += ("org.scala-js" %%% "scalajs-java-logging" % "1.0.0").cross(CrossVersion.for3Use2_13),
5152
// TODO: switch to ModuleES ?

shared/src/main/scala/gopher/ReadChannel.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ trait ReadChannel[F[_], A]:
5252
* Can be used only inside async block.
5353
* If stream is closed and no values to read left in the stream - throws StreamClosedException
5454
**/
55-
transparent inline def read()(using CpsMonadContext[F]): A = await(aread())(using rAsyncMonad)
55+
transparent inline def read[G[_]]()(using mc:CpsMonadContext[G]): A = await(aread())(using rAsyncMonad, mc)
5656

5757
/**
5858
* Synonim for read.
5959
*/
60-
transparent inline def ?(using CpsMonadContext[F]) : A = await(aread())(using rAsyncMonad)
60+
transparent inline def ?(using mc:CpsMonadContext[F]) : A = await(aread())(using rAsyncMonad, mc)
6161

6262
/**
6363
* return F which contains sequence from first `n` elements.

shared/src/main/scala/gopher/Select.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Select[F[_]](api: Gopher[F]):
6767
}
6868
}
6969

70-
transparent inline def afold[S](s0:S)(inline step: S => S | SelectFold.Done[S]) : F[S] =
70+
transparent inline def afold[S](s0:S)(inline step: CpsMonadContext[F] ?=> S => S | SelectFold.Done[S]) : F[S] =
7171
given CpsAsyncMonad[F] = api.asyncMonad
7272
async[F]{
7373
fold(s0)(step)

shared/src/main/scala/gopher/monads/ReadChannelCpsMonad.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import cps._
66
import gopher.impl._
77

88

9-
given ReadChannelCpsMonad[F[_]](using Gopher[F]): CpsMonad[[A] =>> ReadChannel[F,A]] with CpsMonadInstanceContext[[A] =>> ReadChannel[F,A]] with
9+
10+
given ReadChannelCpsMonad[F[_]](using Gopher[F]): CpsMonadInstanceContext[[A] =>> ReadChannel[F,A]] with
1011

1112

1213
def pure[T](t:T): ReadChannel[F,T] =

shared/src/test/scala/gopher/monads/ChannelMonadSuite.scala

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import scala.concurrent.*
88
import scala.concurrent.duration.*
99
import scala.collection.SortedSet
1010

11-
import cps.monads.FutureAsyncMonad
12-
import gopher.monads.given
11+
import cps.monads.{given,*}
12+
import gopher.monads.{given,*}
1313

1414
class ChannelMonadSuite extends FunSuite {
1515

@@ -19,17 +19,21 @@ class ChannelMonadSuite extends FunSuite {
1919

2020
test("using channel as monad and read inside") {
2121

22-
val chX = ReadChannel.fromValues(1,2,3,4,5)
23-
val chY = ReadChannel.fromValues(1,2,3,4,5)
22+
23+
val chX = ReadChannel.fromValues[Future,Int](1,2,3,4,5)
24+
val chY = ReadChannel.fromValues[Future,Int](1,2,3,4,5)
2425

25-
val squares = async[[X] =>> ReadChannel[Future,X]] {
26-
val x = await(chX)
26+
27+
val squares: ReadChannel[Future,Int] = async[[X] =>> ReadChannel[Future,X]] {
28+
val x: Int = await(chX)
2729
//println(s"reading from X $x")
28-
val y = chY.read()
30+
val y: Int = chY.read()
2931
//println(s"reading from Y $y")
3032
x*y
3133
}
34+
3235

36+
3337
async[Future] {
3438
val a1 = squares.read()
3539
//println(s"a1==${a1}")
@@ -46,6 +50,7 @@ class ChannelMonadSuite extends FunSuite {
4650
}
4751

4852
}
53+
4954

5055
test("using channel with flatMap") {
5156

0 commit comments

Comments
 (0)