Trivia at term-level
In this section, we look at lazy patterns, using the magic hash, controlling inlining and using rewrite rules. These are small things used rarely in applications, but nevertheless are very convenient where applicable.
We'll start with lazy patterns. Where strict pattern annotations use bangs and mean "Evaluate this argument to WHNF immediately," lazy pattern annotations use tildes and imply "Don't even bother pattern-matching unless a binding is really requested." So this errors:
> let f (a,b) = 5 > f undefined *** Exception: Prelude.undefined
But with a lazy pattern match, we are all okay:
> let f ~(a,b) = 5 > f undefined 5
A more realistic use case for lazy patterns is the classic server-client setting. The client makes requests ...