Skip to content

Instantly share code, notes, and snippets.

@ymasory
Created May 12, 2012 16:28
Show Gist options
  • Save ymasory/2667462 to your computer and use it in GitHub Desktop.
Save ymasory/2667462 to your computer and use it in GitHub Desktop.
printing an infinite Stream with Scalaz effects
import scalaz._
import Scalaz._
import effects._
object Main extends App {
/* Haskell-style pure main */
def pmain: IO[Unit] = {
val infiniteStream: Stream[String] = Stream continually "hello, world"
infiniteStream.foldr(().pure[IO]) { (el, acc) =>
for {
_ <- putStrLn(el)
_ <- acc
} yield ()
}
}
pmain.unsafePerformIO
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment