Safe Haskell | None |
---|---|
Language | Haskell2010 |
Documentation
A Fact p
is an implicit proof of p
, propagated by Haskell's constraint solver.
Fact
s can be used to implicitly introduce or propagate proofs. However, there is
a small run-time cost associated with using Fact
s: typeclass dictionaries for
Fact
s are still passed around. In many cases they will be optimized away, but this
is not guaranteed.
on :: Fact (p n) => (Proof (p n) -> Proof q) -> (a ~~ n) -> Proof q Source #
Apply an implication to a predicate in the implicit context. The (a ~~ n)
parameter is not actually used; it's type is used to help select a specific
fact from the context.
@
-- A safe head
function, using an implicitly-passed safety proof.
head :: Fact (IsCons xs) => ([a] ~~ xs) -> a
head xs = Prelude.head (the xs)