Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ lazy val reset =
`keywords-Typed`,
`keywords-Return`,
`keywords-FlatMap`,
`keywords-WithFilter`,
`keywords-Match`,
`keywords-Suspend`,
`keywords-Pure`,
Expand All @@ -36,7 +35,6 @@ lazy val `domains-Task` =
reset,
`domains-Continuation`,
`keywords-In` % Test,
`keywords-Fork` % Test,
`keywords-Each` % Test,
`keywords-Using` % Test,
`keywords-Yield` % Test,
Expand All @@ -55,7 +53,6 @@ lazy val `keywords-Fork` =
Dsl,
reset,
`keywords-Shift`,
`keywords-Continue`,
`keywords-ForEach`,
`keywords-In`
)
Expand Down Expand Up @@ -110,11 +107,6 @@ lazy val `keywords-Return` =
.crossType(CrossType.Pure)
.dependsOn(Dsl)

lazy val `keywords-Continue` =
crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.dependsOn(Dsl)

lazy val `keywords-Get` =
crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
Expand Down Expand Up @@ -153,21 +145,11 @@ lazy val `keywords-Using` =
.crossType(CrossType.Pure)
.dependsOn(Dsl, reset, `keywords-Shift`)

lazy val `keywords-Map` =
crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.dependsOn(Dsl, reset % Test)

lazy val `keywords-FlatMap` =
crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.dependsOn(Dsl, `keywords-Pure`)

lazy val `keywords-WithFilter` =
crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.dependsOn(`keywords-Continue`)

lazy val `keywords-NoneSafe` =
crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
Expand Down Expand Up @@ -212,7 +194,6 @@ lazy val `keywords-Yield` =
`keywords-Each` % Test,
`keywords-Shift` % Test,
`keywords-In` % Test,
`keywords-Continue` % Test
)

lazy val `keywords-Monadic` =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.thoughtworks.dsl.Dsl.{!!}
import org.scalatest.Assertion
import scala.language.implicitConversions

import com.thoughtworks.dsl.keywords.{Using, Each, Fork}
import com.thoughtworks.dsl.keywords.{Using, Each}
import com.thoughtworks.dsl.domains._
import com.thoughtworks.dsl.keywords.Shift
import com.thoughtworks.dsl.keywords.Shift.given
Expand Down Expand Up @@ -43,7 +43,7 @@ final class taskSpec extends AsyncFreeSpec with Matchers {
val task1: Task[Int] = Task.now(1)

val ts = *[Task]/* .join */ apply Seq {
!Fork(0 until 10) + !Shift(task1)
!Each(0 until 10) + !Shift(task1)
}

!Shift(ts) should be(1 until 11)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import scala.util.control.TailCalls.TailRec
*
* @template
* @example A [[Task]] can be created from `for`-comprehension,
* where [[keywords.Each]] and [[keywords.Fork]] can be used together to asynchronously iterate collections.
* where [[keywords.Each]] can be used together to asynchronously iterate collections.
*
* For example, the above `concatenateRemoteData` downloads and concatenates data from multiple URLs.
*
Expand All @@ -31,7 +31,7 @@ import scala.util.control.TailCalls.TailRec
* import java.net.URL
* def concatenateRemoteData(urls: List[URL], downloader: URL => Task[Vector[Byte]]) = ToView {
* for {
* url <- Fork(urls)
* url <- Each(urls)
* data <- Shift(downloader(url))
* byte <- Each(data)
* } yield byte
Expand Down
1 change: 0 additions & 1 deletion keywords-Continue/.js/build.sbt

This file was deleted.

1 change: 0 additions & 1 deletion keywords-Continue/.jvm/build.sbt

This file was deleted.

21 changes: 0 additions & 21 deletions keywords-Continue/build.sbt

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ object Each {
transparent inline def unary_! : A =
Dsl.shift(Each(asFA(fa))): A

implicit def eachDsl[Element, Domain, DomainElement](implicit
thatIsTraversableOnce: (Element => Domain) => (Element => GenTraversableOnce[DomainElement]),
factory: Factory[DomainElement, Domain]
): Dsl[Each[Element], Domain, Element] =
new Dsl[Each[Element], Domain, Element] {
def cpsApply(keyword: Each[Element], handler: Element => Domain): Domain = {
flatMapBreakOut(keyword.elements, thatIsTraversableOnce(handler))
}
}

private def toLinearSeq[Element](
i: IterableOnce[Element]
): LinearSeq[Element] = {
Expand Down Expand Up @@ -108,7 +98,7 @@ object Each {
}
)
case None =>
viewHandler(Nil.view)
viewHandler(View.Empty)
}
}
loop(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@ import com.thoughtworks.dsl.reset, reset._
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers

/** @author 杨博 (Yang Bo)
/** @author
* 杨博 (Yang Bo)
*/
class EachSpec extends AnyFreeSpec with Matchers {

"reset helper" - {

"@reset parameter" in {
val seq = 1 to 10
def run(): Seq[Int] = *[Seq] {
def run(): Seq[Int] = reset(Seq {
val plus100 = reset(Seq {
!Each(seq) + 100
})
plus100.length should be(10)
!Each(plus100)
}
})

val result = run()
result.length should be(10)
Expand All @@ -29,13 +30,13 @@ class EachSpec extends AnyFreeSpec with Matchers {

"reset block" in {
val seq = 1 to 10
def run(): Seq[Int] = *[Seq] {
def run(): Seq[Int] = reset(Seq {
val plus100 = reset {
Seq(!Each(seq) + 100)
}
plus100.length should be(10)
!Each(plus100)
}
})

val result = run()
result.length should be(10)
Expand All @@ -44,13 +45,13 @@ class EachSpec extends AnyFreeSpec with Matchers {

"block without reset should behave the same as a block with a reset" in {
val seq = 1 to 10
def run(): Seq[Int] = *[Seq] {
def run(): Seq[Int] = reset {
val plus100 = {
val element = !Each(seq)
Seq(element + 100)
}
plus100.length should be(10)
!Each(plus100)
Seq(!Each(plus100))
}

val result = run()
Expand All @@ -66,12 +67,12 @@ class EachSpec extends AnyFreeSpec with Matchers {
"explicit @reset" in {
val seq = 1 to 10

def run(): Seq[Int] = *[Seq] {
def run(): Seq[Int] = reset {
val plus100: Seq[Int] = Seq {
!Each(seq) + 100
}
plus100.length should be(1)
!Each(plus100)
Seq(!Each(plus100))
}

val result = run()
Expand All @@ -82,12 +83,12 @@ class EachSpec extends AnyFreeSpec with Matchers {
"val" in {
val seq = 1 to 10

def run(): Seq[Int] = *[Seq] {
def run(): Seq[Int] = reset {
val plus100 = Seq {
!Each(seq) + 100
}
plus100.length should be(1)
!Each(plus100)
Seq(!Each(plus100))
}

val result = run()
Expand All @@ -98,12 +99,12 @@ class EachSpec extends AnyFreeSpec with Matchers {
"def" in {
val seq = 1 to 10

def run(): Seq[Int] = *[Seq] {
def plus100 = *[Seq] {
def run(): Seq[Int] = reset {
def plus100 = reset apply Seq {
!Each(seq) + 100
}
plus100.length should be(10)
!Each(plus100)
Seq(!Each(plus100))
}

val result = run()
Expand All @@ -115,8 +116,8 @@ class EachSpec extends AnyFreeSpec with Matchers {

"default parameter" in {

def foo(s: Seq[Int] = *[Seq] {
!Each(Seq(1, 2, 3)) + 100
def foo(s: Seq[Int] = reset {
Seq(!Each(Seq(1, 2, 3)) + 100)
}) = s

foo() should be(Seq(101, 102, 103))
Expand All @@ -125,8 +126,8 @@ class EachSpec extends AnyFreeSpec with Matchers {

"val in class" in {
class C {
val ascii: Set[Int] = *[Set](
!Each(Seq(1, 2, 3, 2)) + 100
val ascii: Set[Int] = reset(
Set(!Each(Seq(1, 2, 3, 2)) + 100)
)
}

Expand All @@ -136,13 +137,15 @@ class EachSpec extends AnyFreeSpec with Matchers {
"pattern matching" - {
"val" in {
def foo: Seq[String] =
*[Seq] {
reset {
// OK
val s0 = !Each(Seq("a"))

// not OK
val (s1, s2) = !Each(Seq(("b", "c")))
s1
// How to support the following use case?
// val (s1, s2) = !Each(Seq(("b", "c")))

val Seq(s1, s2) = !Each(Seq(Seq("b", "c")))
Seq(s1)
}

foo should be(Seq("b"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class ForEachSpec extends AnyFreeSpec with Matchers {
val seq = 1 to 10

def run(): Unit = reset[Unit] {
def plus100 = *[Seq] {
def plus100 = reset apply Seq(
!Each(seq) + 100
}
)
plus100.length should be(10)
!ForEach(plus100)
}
Expand Down
1 change: 0 additions & 1 deletion keywords-Fork/.js/build.sbt

This file was deleted.

1 change: 0 additions & 1 deletion keywords-Fork/.jvm/build.sbt

This file was deleted.

Empty file removed keywords-Fork/build.sbt
Empty file.
Loading