[Haskell-cafe] What is your favourite Haskell "aha" moment?
Johannes Waldmann
johannes.waldmann at htwk-leipzig.de
Wed Jul 11 12:46:02 UTC 2018
When teaching, I like to present
Property based testing - because it is so useful in itself,
and it shows the power of type-level computation -
the compiler constructs the dictionaries,
both for testing (class Testable p),
and for generating test data (class Serial a),
just from the type of the property to be tested.
I guess that Java folks could do this via reflection?
But the popular benchmark these days is not Java - it's Python?
Then it's good because there's no types that would help.
Exact choice of framework - (quick|small|lean)check
does not matter much for an introductory presentation.
I do have a preference for enumeration by size (leancheck)
not by depth (smallcheck) or randomly (quick).
But then, smallcheck can enumerate functions, which is useful
from the beginning (if you want to show properties
of higher order functions).
But then, proving is better than testing,
so you might want to mention "theorems for free"?
But again - the JS programmer's reaction will be:
obtain a theorem from a type? what's a type?
- J.W.
More information about the Haskell-Cafe
mailing list