|
Scala example source code file (IterateeTTest.scala)
The IterateeTTest.scala Scala example source code
package scalaz
package iteratee
import std.AllInstances._
import Free.Trampoline
import Iteratee._
import effect._
import Id._
object IterateeTTest extends SpecLite {
"head" in {
(head[Int, Id] &= enumStream(Stream(1, 2, 3))).run must_===(Some(1))
}
"consume" in {
(consume[Int, Id, List] &= enumStream(Stream(1, 2, 3))).run must_===(List(1, 2, 3))
}
"fold in constant stack space" in {
val iter = fold[Int, Id, Int](0){ case (a,v) => a + v }.up[Trampoline]
val enum = enumStream[Int, Trampoline](Stream.fill(10000)(1))
(iter &= enum).run.run must_===(10000)
}
object instances {
object iterateet {
def monad[F[_]: Monad, E] = Monad[IterateeT[E, F, ?]]
def liftIO[F[_]: MonadIO, E] = LiftIO[IterateeT[E, F, ?]]
def monadIO[F[_]: MonadIO, E] = MonadIO[IterateeT[E, F, ?]]
}
object iteratee {
def monad[E, F] = Monad[Iteratee[E, ?]]
}
}
}
Other Scala examples (source code examples)Here is a short list of links related to this Scala IterateeTTest.scala source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.