This library allows for stronger and more refined types in Elm for both library writer and end users.
Sometimes we want to create "proofs" that is dependent other other data or other systems - for example a API backend. We can use a "Context" to describe under which scenario the proof holds. Note, there is value to describe the context even if other proofs is not used.
For example: cozyAnimals : ForVersionOf BackendResponse (Proved (List CozyAnimals) NonEmptyList) Would mean that for a given backendresponse we have proved that the list of cozy animals is non empty In a different part of the code we could have this type: animal : ForVersionOf BackendResponse (Proved Animal CozyAnimal) Which would mean that for a given backend response we have proved that the animal in question is a cozy animal Then in a third part of the code we have both the cozyAnimals and the animal value To see if the proofs are based on the same backend response we would
firstCheck : Maybe (ForVersionOf BackendResponse (Proved (List CozyAnimals) NonEmptyList, Proved Animal CozyAnimal)
firstCheck = proveSameVersion cozyAnimals animal
-- Continue here, deciding what to do if the proofs came from two different API responses Context is more generalized data type that Version is based upon. This is useful if a specific v
is prefered or needed instead of just a 'random' number.
For example: type alias Ears = Int type AnimalName = AnimalName String p : For AnimalName (Proven Ears Positive) p = ...
-- For: is the name for a Contexbased expression
-- AnimalName: is the constructor that is *not* exported by the Animal-module RefinementProofs.to ensure that no one
-- else can create an AnimalName context and rewire the proofs
-- Proven Ears Positive: The actual expression that is in the described contextBoth "p1" and "p2" holds
"p1" or "p2" holds
A negation of a proof
Implies that if "p1" holds than "p2" holds
Used by library writers to create axioms with non-exported constructors. Remember, the library/module RefinementProofs.constructors must not be exported!
If a is proven to hold property p1 then classic logic gives that a holds either p1 or p2
Same as introOrR but introduces the p2 on the other side
A convience method to check two proofs for Or
A convience method to check two proofs at once for And
Used by library writers to show that when p1 does not hold for a then Not p1 holds.
Extract the actual value and remove the proof. This is always safe and a library writer should always expect and allow its users to do this.
If a library implies that when p1 holds the p2 holds then you have proven p2 by prove p1
Synonym for "modus ponens". If a library implies that when p1 holds the p2 holds then you have proven p2 by prove p1
If a library implies that when p1 holds the p2 holds then you have proven (Not p2) by prove (Not p1)
Synonym for "modus tollens". If a library implies that when p1 holds the p2 holds then you have proven (Not p2) by prove (Not p1)
A value "a" that is proven to hold the property "b"