Skip to content

Instantly share code, notes, and snippets.

@drstevens
Last active December 17, 2015 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save drstevens/5579549 to your computer and use it in GitHub Desktop.
Save drstevens/5579549 to your computer and use it in GitHub Desktop.
Attempt to sequence List[StateT[Trampoline,A,B]]] with Trampoline in Scalaz 7. Unable to get this to work in scala 2.9.2 REPL. Works in 2.10.1 REPL. See https://gist.github.com/larsrh/5579789 also
import scalaz.std.anyVal._
import scalaz.std.tuple._
import scalaz.std.option._
import scalaz.StateT
import scalaz.State
import scalaz.Free
import scalaz.Free._
import scalaz.State._
import scalaz.Trampoline._
import scalaz.syntax.traverse._
import scalaz.std.list._
val plus1Tr = StateT[Free.Trampoline, Long, Long](s => trampolineMonad.pure((s + 1, s + 1)))
//plus1Tr: scalaz.package.StateT[scalaz.Free.Trampoline,Long,Long]
val lOpTr = List.fill(100000)(plus1Tr)
// lOpTr: List[scalaz.package.StateT[scalaz.Free.Trampoline,Long,Long]]
val pOlTr = lOpTr.sequence[({type λ[α]=StateT[Free.Trampoline, Long, α]})#λ, Long]
// <console>:36: error: could not find implicit value for parameter G: scalaz.Applicative[[α]scalaz.IndexedStateT[[+A]scalaz.Free[Function0,A],Long,Long,α]]
// val pOlTr = lOpTr.sequence[({type λ[α]=StateT[Free.Trampoline, Long, α]})#λ, Long]
//It was suggested that I try sequenceU
val pOlTr: StateT[Free.Trampoline, Long, List[Long]] = lOpTr.sequenceU
// <console>:36: error: type mismatch;
// found : G.M[List[G.A]]
// required: scalaz.package.StateT[scalaz.Free.Trampoline,Long,List[Long]]
// val pOlTr: StateT[Free.Trampoline, Long, List[Long]] = lOpTr.sequenceU
val result = pOlTr.evalZero[Long]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment