alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (IterateeTTest.scala)

This example Scala source code file (IterateeTTest.scala) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Scala by Example" TM.

Learn more about this Scala project at its project page.

Java - Scala tags/keywords

int, iterateettest, liftio, list, monad, monadio, speclite

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

 

new blog posts

 

Copyright 1998-2021 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.