Equational reasoning at scale
haskellforall.com
haskellforall.com
Explain how to make HTTP requests, query databases, load balance web servers or write GUI's. And then explain how equational reasoning can be useful there.
My personal experience is that equational reasoning quickly falls apart as soon as you go beyond toy examples such as the ones shown in this article, but I'm dying to be proven wrong.
http://www.haskellforall.com/2014/06/spreadsheet-like-progra...
That shows a spreadsheet that you assemble using Applicative and Monoid operations that is built on top of several abstraction layers, and the correctness proof of each layer buulds on the previous proofs.
[0] http://www.amazon.co.uk/Pearls-Functional-Algorithm-Design-R...
it's on my list but have somewhat procrastinated due to the perceived difficulty mentioned above.
For when you end up reading it so that you are not pulling your hair out as to why the code isn't working: there is a code error in chapter 4.
There's a pedagogical difficulty in showing a very complex problem: the article is already quite long, and just the showing of a complex problem is, well, complex. It reminds me of the difficulty of teaching a one-semester course in Software Engineering: you need a large project before software engineering principles start to be needed; but developing a large project is more than semester's work in itself...
I'm not sure there is an answer to this, for equational reasoning. It seems some tradeoff/sacrifice is needed; something must be given up. Maybe: only summarise the project and sketch out the proof (like those of professional mathematicians) - the tradeoff is that this is no longer elementary from first principles, and would be inaccessible to newcomers. Maybe a "201" blog post, that has as prerequisites some of your "101" blog posts?
There's certainly a need to have an actual complex project to prove. Could be one of your own; building one specifically for this (so the complexity is not overwhelming; and minimize interactions); or choose some existing complex project off the shelf. Probably needs to be an objectively convincingly complex one (so not one that is intrinsically tied to addressing problems within Haskell itself). For example, not an IO monad, but some application that is complex no matter what language it's written in.
Ironically, perhaps some of the "web-scale" examples would be most complelling...
EDIT just saw some of your comments, and it looks like you're doing pretty much this already. :)
If you're looking for a 'real world' use of the monoid laws and the way the compiler can build them up for you, you might want to have a look at [0] Monoids: Themes and Variations, where the author shows how these ideas work themselves out in a quite nontrivial diagramming library.
In Agda it looks like this: https://github.com/solomatov/AgdaSandbox/blob/master/Monoid.... Here we prove that in a monoid if a inverse element exists, then it's unique.
Assuming your aim is to spread awareness of the advantages of pure functional programming, rather than of Haskell specifically, I wonder if your Haskell-specific domain name is muddling your message?
Tonight I will revise this post to be less Haskell-centric by mentioning that most of what it describes applies to other purely functional languages and also mention how dependently typed languages can improve and mechanically check the proof process.
Downvote all you want for off-topicness; I'm reveling in enlightenment.
It doesn't seem that hard, at least when it comes to these algebraic proofs; let the programmer build up proofs and lemmas by applying legal equational substitutions. Then let him reuse them in new proofs. The only responsibility of the program might be that it checks that all transitions are legal. Then you just have a verifier/checker, not even an automatic prover or anything. Does anything like this exist?
Assuming that all Monoid instances obey the monoid laws is a pretty reasonable thing to do even if you haven't proven every single instance yourself. It's the same as assuming that a Set<T> in e.g. Java actually obeys the set abstraction: has no duplicates, ordering is not guaranteed, etc. In practice the laws associated with type classes are a bit better specified in Haskell via either terse (algebraic) documentation or default implementations of associated functions. It would perhaps be nice if libraries which export type classes came with test functions that could be used to test your instances using some sort of QuickCheck-like approach.
Though I've personally found that Haskell is sufficient at least my purposes, Idris currently seems the most "practical" of the dependently typed languages, but it's quite young and doesn't really have any ecosystem to speak of AFAICT.