unfiltered/unfiltered — pull request #179 by teigen (2013-09-08 07:00:44+00:00)
Title: Improving commit semantics

Previously the API provided two mechanisms for controlling backtracking: `commit` and `autocommit`. `commit` wrapped a directive, rewriting Failure results to Errors, while autocommit wrapped a directive with an altered flatMap to commit the directive taken as a parameter to flatMap.

After explaining `commit` and `autocommit` to users and seeing it in use, it's pretty clear that not only is `autocommit` poorly named - it's very confusing and non-obvious.

The changes in this commit tries to improve this situation by deprecating `autocommit` and instead turning `commit` into a directive itself (with an additional `apply` method with the behaviour of the previous `commit` method - keeping `commit` mostly backwards source compatible). The new api should make it much more obvious to users when directives are committed and how to control backtracking

// deprecated autocommit api
val a = for {
_ <- autocommit(GET)
_ <- failure(BadRequest)
} yield ...

// new "autocommit" api
val a = for {
_ <- GET
_ <- commit
_ <- failure(BadRequest)
} yield ...

// unchanged "old" commit api
val a = for {
_ <- GET
_ <- commit(failure(BadRequest))
} yield ...