Last active
December 17, 2015 08:19
-
-
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
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 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