Liquid Haskell compains on partial functions.
Similar to ghc -W
's
Pattern match(es) are non-exhaustive
In an equation for ‘myHead’: Patterns not matched: []
|
46 | myHead (x:_) = x
| ^^^^^^^^^^^^^^^^
[❤ ghc] ghc tells you the missing patterns
[❤ LH] Liquid Haskell allows for Haskell partial functions
{-@ myHead :: xs:{[a] | 0 < len xs } -> a @-}
Pattern match(es) are non-exhaustive
In an equation for ‘swap’: Patterns not matched: (_:_:_)
Q: What if the input list is ordered, encoded as OList a
?
Q: Does fib
terminate?
Check that the first inductive argument is decreasing at each recursive call.
If the check fails, then
Q: Can you spot the merge
error?
Q: Does it still terminate?
Q: Let's prove the result is ordered (OList a
) too!
Liquid Haskell checks, by default, termination & totality.
You can deactivate it via --no-termination
and --no-totality
, resp..
Observation: Functions that are total & terminating are really math functions! Let's use them to encode proofs!