Skip to content

Commit

Permalink
Merge pull request #878 from ceedubs/fix-freemonad-doc
Browse files Browse the repository at this point in the history
Fix bug in freemonad doc
  • Loading branch information
adelbertc committed Feb 21, 2016
2 parents 6fe593d + ee36b14 commit fa20a49
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions docs/src/main/tut/freemonad.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,14 @@ value store:
import cats.{Id, ~>}
import scala.collection.mutable
// a very simple (and imprecise) key-value store
val kvs = mutable.Map.empty[String, Any]
// the program will crash if a key is not found,
// or if a type is incorrectly specified.
def impureCompiler =
def impureCompiler: KVStoreA ~> Id =
new (KVStoreA ~> Id) {
// a very simple (and imprecise) key-value store
val kvs = mutable.Map.empty[String, Any]
def apply[A](fa: KVStoreA[A]): Id[A] =
fa match {
case Put(key, value) =>
Expand Down Expand Up @@ -274,7 +275,7 @@ val pureCompiler: KVStoreA ~> KVStoreState = new (KVStoreA ~> KVStoreState) {
fa match {
case Put(key, value) => State.modify(_.updated(key, value))
case Get(key) =>
State.pure(kvs.get(key).map(_.asInstanceOf[A]))
State.inspect(_.get(key).map(_.asInstanceOf[A]))
case Delete(key) => State.modify(_ - key)
}
}
Expand Down

0 comments on commit fa20a49

Please sign in to comment.