Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add EmbeddedTraversable

  • Loading branch information...
commit 9b2cb22d2ec6911b87a0bbfba8e98ef3c9512c96 1 parent 6ec0323
@urso authored
Showing with 11 additions and 2 deletions.
  1. +11 −2 src/main/scala/embeddedmonads/embeddedmonads.scala
View
13 src/main/scala/embeddedmonads/embeddedmonads.scala
@@ -32,8 +32,8 @@ object EmbeddedOption extends EmbeddedMonad[Option] {
runMonad(ctx)
}
-object EmbeddedSeq extends EmbeddedMonad[Seq] {
- def runSeq[C](ctx: => Any @cpsParam[Seq[Any], Seq[Any]]) : Seq[C] =
+object EmbeddedTraversable extends EmbeddedMonad[Traversable] {
+ def runTraversable[C](ctx: => Any @cpsParam[Traversable[Any], Traversable[Any]]) : Traversable[C] =
runMonad(ctx)
def guard[A](b:Boolean) = shift { k:(Unit => Seq[Any]) =>
@@ -50,6 +50,15 @@ object EmbeddedIterable extends EmbeddedMonad[Iterable] {
}
}
+object EmbeddedSeq extends EmbeddedMonad[Seq] {
+ def runSeq[C](ctx: => Any @cpsParam[Seq[Any], Seq[Any]]) : Seq[C] =
+ runMonad(ctx)
+
+ def guard[A](b:Boolean) = shift { k:(Unit => Seq[Any]) =>
+ if (b) k() else Seq()
+ }
+}
+
class EmbeddedState[S] extends EmbeddedMonad[PartialApply1Of2[State,S]#Apply] {
}
Please sign in to comment.
Something went wrong with that request. Please try again.