Sometimes, we want to prove properties that require more complex reasoning and/or cannot easily be attached to the type of one particular function.
Liquid Haskell provides proof combinators for this purpose.
Let's use a more classic version of lookup tables as the basic for our properties.
Our lookup function returns a Maybe
now:
And delete
is as before:
In order to prove theorems about lookup
and delete
, we have to be able to talk about them in types.
But we cannot make them measures, because they have more than one argument.
However, we can use reflect
instead. (This requires passing the --exact-data-cons
flag to Liquid Haskell.)
Let's also prove some properties on lists. We use our own version of lists again.