Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in freemonad doc #878

Merged
merged 2 commits into from
Feb 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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