Skip to content

Instantly share code, notes, and snippets.

View Refefer's full-sized avatar

Andrew Stanton Refefer

  • San Francisco
View GitHub Profile
@tonymorris
tonymorris / IO.scala
Created November 5, 2013 23:57
Pure-functional IO in Scala
sealed trait IOOperation[A] {
def map[B](f: A => B): IOOperation[B] =
this match {
case PutChar(c, a) =>
PutChar(c, f(a))
case GetChar(g) =>
GetChar(f compose g)
}
}
case class PutChar[A](c: Char, a: A) extends IOOperation[A]