|
Scala example source code file (STTest.scala)
The STTest.scala Scala example source codepackage scalaz package effect import std.AllInstances._ import ST._ object STTest extends SpecLite { type ForallST[A] = Forall[ST[?, A]] "STRef" in { def e1[S] = for { x <- newVar[S](0) r <- x mod {_ + 1} } yield x def e2[S]: ST[S, Int] = for { x <- e1[S] r <- x.read } yield r runST(new ForallST[Int] { def apply[S] = e2[S] }) must_===(1) } "STArray" in { def e1[S] = for { arr <- newArr[S, Boolean](3, true) _ <- arr.write(0, false) r <- arr.freeze } yield r runST(new ForallST[ImmutableArray[Boolean]] { def apply[S] = e1[S] }).toList must_===( List(false, true, true)) } } Other Scala examples (source code examples)Here is a short list of links related to this Scala STTest.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 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.