yet another equivalent of a biased scala.Either: Okay/Reason extends Checked, complete with <*>.
Scala
Latest commit db75584 Jun 11, 2012 @robcd TestsInvolvingOption: toHead renamed toHeadOption; README.md: a few w…
…ords in Example code links changed to fixed-width font
Permalink
Failed to load latest commit information.
project
src
.gitignore
README.md
build.sbt
musicians.db

README.md

Checking is a trait (very like EitherExtras), that provides (yet) a(nother) biased alternative to scala.Either, a 'fixed' version of which is to be found here.

This alternative is called Checked, whose only subclasses are Okay and Reason.

It is for use as the return type, in place of some type, A, wherever an exception might otherwise be thrown and a more 'functional' style is preferred. Thus, a Checked[A, R] will contain either an A wrapped in an instance of Okay or else an R wrapped in an instance of Reason, depending on whether or not an exceptional condition arose.

Note that although Checked provides map and flatMap, it does not provide filter or withFilter, since it was concluded that an empty result is not appropriate.

The same 'extras' provided for scala.Either by EitherExtras are also provided for Checked by Checking, including the ability to check multiple values at once using the <*> operator. Note that 'fast' and 'slow' have now become 'ff' (fail-fast) and 'fs' (fail-slowly), respectively.

Example code

for comprehension tests
'lift' tests
<*> tests
<*> tests with multiple checks
case-class tests
'SaturdayNight' tests
tests involving Option
Musicans
printMusicians

Artifacts

org.lafros artifacts in Maven central repository
org.lafros artifacts in Sonatype mirror