Skip to content

Instantly share code, notes, and snippets.

@pchiusano
Last active September 30, 2015 01:49
Show Gist options
  • Save pchiusano/cf6e6f1b1271c113d1a1 to your computer and use it in GitHub Desktop.
Save pchiusano/cf6e6f1b1271c113d1a1 to your computer and use it in GitHub Desktop.
Some simple primitives for inverting control in FS2
trait Ack[+W]
object Ack {
case class Accept(unprocessedSize: Int) extends Ack[Nothing]
case class Halt(unprocessed: Seq[W]) extends Ack[W]
case class Fail(err: Throwable, unprocessed: Seq[W]) extends Ack[W]
}
trait Input[+W]
object Input {
case class Send[W](chunk: Chunk[W]) extends Input[W]
case object Done extends Input[Nothing]
case class Fail(err: Throwable) extends Input[Nothing]
}
def asyncs[W](register: (Input[W] => Ack[W]) => Unit): Task[Stream[Task,W]] = ???
def signal[W](w: W)(register: (Input[W] => Ack[W]) => Unit): Task[Stream[Task,W]] = ???
@pchiusano
Copy link
Author

Might want asyncs and signal to take a Strategy.

@pchiusano
Copy link
Author

To convert result of signal to a continuous version:

def hold[F[_]:Async,A](p: Stream[F,A]): Stream[F,A]

@pchiusano
Copy link
Author

Not sure about the names asyncs and signal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment