Created
May 31, 2014 13:40
-
-
Save travisbrown/58f289c69ac74d2e6d7e to your computer and use it in GitHub Desktop.
Trampolining the state monad (doesn't work)
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._, Scalaz._ | |
def setS(i: Int): State[List[Int], Unit] = modify(i :: _) | |
val s = (1 to 10000).foldLeft(state[List[Int], Unit](()).lift[Free.Trampoline]) { | |
case (st, i) => st.flatMap(_ => setS(i).lift[Free.Trampoline]) | |
} | |
s(Nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment