package scalaz.example
object ExampleST {
import scalaz._
import Scalaz._
import effects._
def e1[A] = for {
r <- newVar[A, Int](0)
x <- r.mod(_ + 1)
} yield x
def e2[A] = e1[A].flatMap(_.read)
def test = new Forall[({type λ[S] = ST[S, Int]})#λ] {
def apply[A] = e2
}
def test2 = new Forall[({type λ[S] = ST[S, STRef[S, Int]]})#λ] {
def apply[A] = e1
}
val compiles = runST(test)
def binSort[A: Manifest](size: Int, key: A => Int, as: List[A]): ImmutableArray[List[A]] =
accumArray(size, (vs: List[A], v: A) => v :: vs, List(), for { a <- as } yield (key(a), a))
}