Created
May 12, 2012 16:28
-
-
Save ymasory/2667462 to your computer and use it in GitHub Desktop.
printing an infinite Stream with Scalaz effects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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