Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- head :: Fact (IsCons xs) => ([a] ~~ xs) -> a ~~ Head xs
- tail :: Fact (IsCons xs) => ([a] ~~ xs) -> [a] ~~ Tail xs
- cons :: (a ~~ x) -> ([a] ~~ xs) -> [a] ~~ Cons' x xs
- nil :: [a] ~~ Nil'
- data Head xs
- data Tail xs
- data Cons' x xs
- data Nil'
- data IsList xs
- data IsCons xs
- data IsNil xs
- consIsList :: Proof (IsCons xs) -> Proof (IsList xs)
- nilIsList :: Proof (IsNil xs) -> Proof (IsList xs)
- listIsList :: ([a] ~~ xs) -> Proof (IsList xs)
- listShapes :: Proof (IsList xs) -> Proof ((IsNil xs && Not (IsCons xs)) || (IsCons xs && Not (IsNil xs)))
- consIsCons :: Proof (IsCons (Cons' x xs))
- headOfCons :: Proof (Head (Cons' x xs) == x)
- tailOfCons :: Proof (Tail (Cons' x xs) == xs)
- listInduction :: Proof (IsList xs) -> Proof (p Nil') -> Proof (ForAll ys ((IsList ys && p (Tail ys)) --> p ys)) -> Proof (p xs)
- classify :: ([a] ~~ xs) -> ListCase a xs
- data ListCase a xs
- pattern IsCons :: Proof (IsCons xs) -> (a ~~ Head xs) -> ([a] ~~ Tail xs) -> [a] ~~ xs
- pattern IsNil :: Proof (IsNil xs) -> [a] ~~ xs
- classify' :: forall a xs. ([a] ~~ xs) -> ListCase' a xs
- data ListCase' a xs where
- pattern Cons :: () => Fact (IsCons xs) => (a ~~ Head xs) -> ([a] ~~ Tail xs) -> [a] ~~ xs
- pattern Nil :: () => Fact (IsNil xs) => [a] ~~ xs
Basic functions on lists
head :: Fact (IsCons xs) => ([a] ~~ xs) -> a ~~ Head xs Source #
Extract the first element from a non-empty list.
tail :: Fact (IsCons xs) => ([a] ~~ xs) -> [a] ~~ Tail xs Source #
Extract all but the first element from a non-empty list.
cons :: (a ~~ x) -> ([a] ~~ xs) -> [a] ~~ Cons' x xs Source #
Construct a list from an element and another list.
Names for parts of a list
Names for basic list operations
Reasoning about lists
Predicates about list shapes
Axioms about list shapes
listShapes :: Proof (IsList xs) -> Proof ((IsNil xs && Not (IsCons xs)) || (IsCons xs && Not (IsNil xs))) Source #
Axiom: a list xs
satisfies exactly one of IsCons xs
or IsNil xs
.
Induction principle
listInduction :: Proof (IsList xs) -> Proof (p Nil') -> Proof (ForAll ys ((IsList ys && p (Tail ys)) --> p ys)) -> Proof (p xs) Source #
Induction principle: If a predicate P
is true for the empty list, and
P
is true for a list whenever it is true for the tail of the list,
then P
is true.
Pattern-matching on lists
Decompositions that use explicit evidence-passing
classify :: ([a] ~~ xs) -> ListCase a xs Source #
Classify a named list by shape, producing evidence that the list matches the corresponding case.
Possible shapes of a list, along with evidence that the list has the given shape.
Pattern synonyms
Decompositions that use implicit evidence-passing
classify' :: forall a xs. ([a] ~~ xs) -> ListCase' a xs Source #
Classify a named list by shape, producing implicit evidence that the list matches the corresponding case.
data ListCase' a xs where Source #
A variation on ListCase
that passes the shape facts implicitly. Pattern-matching on a
constructor of ListCase'
will bring a shape proof into the implicit context.