Skip to content

Commit 107ffea

Browse files
committed
adopted do dotty-cps-async-0.9.6
1 parent 6245794 commit 107ffea

16 files changed

+61
-46
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44

55
### Dependences:
66

7-
For scala 3:
7+
For scala 3.1.1+:
8+
9+
libraryDependencies += "com.github.rssh" %% "scala-gopher" % "3.0.0"
10+
11+
For scala 3 and 3.1.0:
812

913
libraryDependencies += "com.github.rssh" %% "scala-gopher" % "2.1.0"
1014

15+
Note, that 3.0.0 have no new functionality agains 2.1.0 but need to be a next major release because of binary incompability caused by difference between dotty-cps-async-0.9.5 and 0.9.6.
16+
1117
For scala2:
1218

1319
libraryDependencies += "com.github.rssh" %% "scala-gopher" % "0.99.15"

build.sbt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
//val dottyVersion = "3.0.0-RC2-bin-SNAPSHOT"
2-
val dottyVersion = "3.1.0"
2+
val dottyVersion = "3.1.1"
33
//val dottyVersion = dottyLatestNightlyBuild.get
44

5-
ThisBuild/version := "2.1.2-SNAPSHOT"
5+
ThisBuild/version := "3.0.0"
66
ThisBuild/versionScheme := Some("semver-spec")
77

88
val sharedSettings = Seq(
99
organization := "com.github.rssh",
1010
scalaVersion := dottyVersion,
1111
name := "scala-gopher",
1212
resolvers += "Local Ivy Repository" at "file://"+Path.userHome.absolutePath+"/.ivy2/local",
13-
libraryDependencies += "com.github.rssh" %%% "dotty-cps-async" % "0.9.4",
13+
libraryDependencies += "com.github.rssh" %%% "dotty-cps-async" % "0.9.6",
1414
libraryDependencies += "org.scalameta" %%% "munit" % "0.7.29" % Test,
1515
)
1616

@@ -45,7 +45,7 @@ lazy val gopher = crossProject(JSPlatform, JVMPlatform)
4545
Compile / doc / scalacOptions := Seq("-groups",
4646
"-source-links:shared=github://rssh/scala-gopher/master#shared",
4747
"-source-links:jvm=github://rssh/scala-gopher/master#jvm"),
48-
mimaPreviousArtifacts := Set( "com.github.rssh" %% "scala-gopher" % "2.1.0")
48+
mimaPreviousArtifacts := Set() //Set( "com.github.rssh" %% "scala-gopher" % "2.1.0")
4949
).jsSettings(
5050
libraryDependencies += ("org.scala-js" %%% "scalajs-java-logging" % "1.0.0").cross(CrossVersion.for3Use2_13),
5151
// TODO: switch to ModuleES ?

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.2")
22
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1")
33
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")
44
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
5-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1")
5+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0")
66
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.0.1")

shared/src/main/scala/gopher/Gopher.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ trait Gopher[F[_]:CpsSchedulingMonad]:
8383
}
8484

8585
end Gopher
86-
86+
8787

8888
/**
8989
* Create Read/Write channel.

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

Lines changed: 14 additions & 10 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(): A = await(aread())(using rAsyncMonad)
55+
transparent inline def read()(using CpsMonadContext[F]): A = await(aread())(using rAsyncMonad)
5656

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

6262
/**
6363
* return F which contains sequence from first `n` elements.
@@ -83,7 +83,7 @@ trait ReadChannel[F[_], A]:
8383
* take first `n` elements.
8484
* should be called inside async block.
8585
**/
86-
transparent inline def take(n: Int): IndexedSeq[A] =
86+
transparent inline def take(n: Int)(using CpsMonadContext[F]): IndexedSeq[A] =
8787
await(atake(n))(using rAsyncMonad)
8888

8989
/**
@@ -107,7 +107,7 @@ trait ReadChannel[F[_], A]:
107107
*
108108
* should be called inside async block.
109109
**/
110-
transparent inline def optRead(): Option[A] = await(aOptRead())(using rAsyncMonad)
110+
transparent inline def optRead()(using CpsMonadContext[F]): Option[A] = await(aOptRead())(using rAsyncMonad)
111111

112112
def foreach_async(f: A=>F[Unit]): F[Unit] =
113113
given CpsAsyncMonad[F] = asyncMonad
@@ -130,7 +130,7 @@ trait ReadChannel[F[_], A]:
130130
* run code each time when new object is arriced.
131131
* until end of stream is not reached
132132
**/
133-
transparent inline def foreach(inline f: A=>Unit): Unit =
133+
transparent inline def foreach(inline f: A=>Unit)(using CpsMonadContext[F]): Unit =
134134
await(aforeach(f))(using rAsyncMonad)
135135

136136

@@ -170,8 +170,8 @@ trait ReadChannel[F[_], A]:
170170
s
171171
}
172172

173-
transparent inline def fold[S](inline s0:S)(inline f: (S,A) => S ): S =
174-
await[F,S](afold(s0)(f))(using rAsyncMonad)
173+
transparent inline def fold[S](inline s0:S)(inline f: (S,A) => S )(using mc:CpsMonadContext[F]): S =
174+
await[F,S,F](afold(s0)(f))(using rAsyncMonad, mc)
175175

176176
def zip[B](x: ReadChannel[F,B]): ReadChannel[F,(A,B)] =
177177
given CpsSchedulingMonad[F] = asyncMonad
@@ -317,14 +317,18 @@ object ReadChannel:
317317
}
318318

319319

320-
320+
321321
import cps.stream._
322322

323-
given emitAbsorber[F[_]: CpsSchedulingMonad,T](using gopherApi: Gopher[F]): BaseUnfoldCpsAsyncEmitAbsorber[ReadChannel[F,T],F,T](
324-
using gopherApi.asyncMonad, gopherApi.taskExecutionContext) with
323+
given emitAbsorber[F[_], C<:CpsMonadContext[F], T](using auxMonad: CpsSchedulingMonad[F]{ type Context = C }, gopherApi: Gopher[F]): BaseUnfoldCpsAsyncEmitAbsorber[ReadChannel[F,T],F,C,T](
324+
using gopherApi.taskExecutionContext, auxMonad) with
325325

326326
override type Element = T
327327

328+
def asSync(fs: F[ReadChannel[F,T]]): ReadChannel[F,T] =
329+
DelayedReadChannel(fs)
330+
331+
328332
def unfold[S](s0:S)(f: S => F[Option[(T,S)]]): ReadChannel[F,T] =
329333
val r: ReadChannel[F,T] = unfoldAsync(s0)(f)
330334
r

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class Select[F[_]](api: Gopher[F]):
2626
*}
2727
*```
2828
*/
29-
transparent inline def apply[A](inline pf: PartialFunction[Any,A]): A =
29+
transparent inline def apply[A](inline pf: PartialFunction[Any,A])(using mc:CpsMonadContext[F]): A =
3030
${
31-
SelectMacro.onceImpl[F,A]('pf, 'api )
31+
SelectMacro.onceImpl[F,A]('pf, 'api, 'mc )
3232
}
3333

3434
/**
@@ -68,7 +68,8 @@ class Select[F[_]](api: Gopher[F]):
6868
}
6969

7070
transparent inline def afold[S](s0:S)(inline step: S => S | SelectFold.Done[S]) : F[S] =
71-
async[F](using api.asyncMonad).apply{
71+
given CpsAsyncMonad[F] = api.asyncMonad
72+
async[F]{
7273
fold(s0)(step)
7374
}
7475

shared/src/main/scala/gopher/SelectForever.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import scala.concurrent.duration._
1212
class SelectForever[F[_]](api: Gopher[F]) extends SelectGroupBuilder[F,Unit, Unit](api):
1313

1414

15-
transparent inline def apply(inline pf: PartialFunction[Any,Unit]): Unit =
15+
transparent inline def apply(inline pf: PartialFunction[Any,Unit])(using mc:CpsMonadContext[F]): Unit =
1616
${
17-
SelectMacro.foreverImpl('pf,'api)
17+
SelectMacro.foreverImpl('pf,'api, 'mc)
1818
}
1919

2020

shared/src/main/scala/gopher/SelectGroup.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ class SelectGroup[F[_], S](api: Gopher[F]) extends SelectListeners[F,S,S]:
7373
def runAsync():F[S] =
7474
retval
7575

76-
transparent inline def apply(inline pf: PartialFunction[Any,S]): S =
76+
transparent inline def apply(inline pf: PartialFunction[Any,S])(using mc: CpsMonadContext[F]): S =
7777
${
78-
SelectMacro.onceImpl[F,S]('pf, 'api )
78+
SelectMacro.onceImpl[F,S]('pf, 'api, 'mc )
7979
}
8080

81-
transparent inline def select(inline pf: PartialFunction[Any,S]): S =
81+
transparent inline def select(inline pf: PartialFunction[Any,S])(using mc: CpsMonadContext[F]): S =
8282
${
83-
SelectMacro.onceImpl[F,S]('pf, 'api )
83+
SelectMacro.onceImpl[F,S]('pf, 'api, 'mc )
8484
}
8585

8686
/**

shared/src/main/scala/gopher/SelectListeners.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ trait SelectListeners[F[_],S, R]:
1616

1717
def runAsync():F[R]
1818

19-
transparent inline def run(): R = await(runAsync())(using asyncMonad)
19+
transparent inline def run()(using CpsMonadContext[F]): R = await(runAsync())(using asyncMonad)
2020

2121

2222

shared/src/main/scala/gopher/SelectLoop.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import java.util.logging.{Level => LogLevel}
1111
class SelectLoop[F[_]](api: Gopher[F]) extends SelectGroupBuilder[F,Boolean, Unit](api):
1212

1313

14-
transparent inline def apply(inline pf: PartialFunction[Any,Boolean]): Unit =
14+
transparent inline def apply(inline pf: PartialFunction[Any,Boolean])(using mc: CpsMonadContext[F]): Unit =
1515
${
16-
SelectMacro.loopImpl[F]('pf, 'api )
16+
SelectMacro.loopImpl[F]('pf, 'api, 'mc )
1717
}
1818

1919
def runAsync(): F[Unit] =

0 commit comments

Comments
 (0)