Validation library for Algebraic Data Types
data Validation a b = Failure a
| Success bAPI
Validation type implements Functor and Applicative typeclasses in fantasy-land spec
instance Functor (Validation a)
instance Monoid a => Applicative (Validation a)additional methods:
fold :: Validation a b ~> (a -> c) -> (b -> c) -> c
isSuccess :: Validation t a ~> bool
fail :: t -> Validation t aexample:
const Person = R.curry(
daggy.tagged('Person', ['name', 'age'])
)
const checkName = name =>
name.length > 2
? Success(name)
: Failure(["name should be more then 2 characters long"])
const checkAge = age =>
age >= 13
? Success(age)
: Failure(["you should be at least 13 years old"])
const lift2 = ctor => x => y => x.map(ctor).ap(y)
const mkPerson = (name, age) => lift2(Person)(name)(age)
mkPerson(
checkName("George Martin"),
checkAge(68)
).toString() // Validation.Success(Person("George Martin", 68))
mkPerson(
checkName("f"),
checkAge(11),
).toString() // Validation.Failure(["name should be more then 2 characters long",
// "you should be at least 13 years old"])
Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
