I am learning Haskell and reading the book, Learn You a Haskell for Great Good!
When the author talks about where keyword, he says:
In imperative programming languages, you would solve this problem by
storing the result of a computation in a variable. In this section,
you’ll learn how to use Haskell’s where keyword to store the results
of intermediate computations, which provides similar functionality.
However I saw the where keyword also following at the end of a module declaration, and I doubt the “intermediate computations” explanation in this scenario, what’s the meaning of the where followed at the end of the module declaration?
Compare:
whereis acting as a syntactic introducer of a scope of definitions. However, I believe it is just a trick, for we cannot say:or
(maybe the latter is legal). I’d like to say that the
moduledeclaration exports (unless otherwise specified) all symbols in scope at the point of declaration; that would be the most consistent. But it’s false, so we can consider it at best an idiosyncracy of the concrete syntax. I thought it was weird for a long time too (and upon further reflection answering this question, still do).