Created
July 17, 2012 23:16
-
-
Save bmjames/3132781 to your computer and use it in GitHub Desktop.
Enumerateaser
This file contains hidden or 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 ALL the things | |
import scalaz._, Scalaz._, iteratee._, Iteratee._, effect._ | |
// An enumerator based on an iterator | |
val input = enumIterator[String, IO](Iterator("a", "bb", "ccc", "dddd")) | |
// An enumeratee which maps strings to their length | |
def strLen[F[_]:Monad] = EnumerateeT.map[String, Int, F](_.length) | |
// An iteratee which prints to System.out | |
val output = putStrTo[Int](System.out) &= (input mapE strLen) | |
// Prints '1234' | |
output.run.unsafePerformIO() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment