markhibberd/argonaut — pull request #36 by markhibberd (2013-04-17 16:46:03+00:00)
Title: Unbreak ACursor.

Megafix. I went into fix a small issue and went down the rabbit hole. Overall I think there are some big improvements and at least half a dozen bug fixes here. But..... it breaks compatibility for anyone who would have been constructing history or custom error messages in their codecs. The changes are obvious (will result in compile errors, and just require call into a different function name).

@seanparsons What say you? I will think about it overnight as well, because pushing this at 3am seems like a bad idea. If there is anything that will break for you guys I will reconsider, otherwise I will probably merge it tomorrow.

Fixes #35.

Fixes #29.

Fixes all ACursor navigation combinators being broken when succeeded == false.

Fixes Map DecodeJson codec.

Prevents accidental use of ACursor cursor when succeeded == false which was responsible for all above issues.

Changed declaration of CursorHistory, HCursor and ACursor from sealed trait to case class, in each
instance there was an attempt to hide construction but it was possible to do anyway. This makes
a few things a lot nicer, and allowed for consisten ok/fail constructor usage.

This commit breaks compatability in a few (good) ways.

- ACursor.hcursor and friends now return option an
can not be called in incorrect state.

- ACursor.unary_- is no longer ambiguous was used for
undo on cursors and validation. undo only now.

This commit breaks compatability in a few (indifferent) ways,
but overall the change comes up as a positive I think.

- DecodeResult, ACursor, HCursor and CursorHistory are now case classes.

- DecodeResult.apply, ACursor.apply and HCursor.apply are now called ok to avoid
overloading on apply and add consistency.

- ACursor.fail*, HCursor.fail* and DecodeResult.fail* are all
just called fail for consistency.