The meaning of the word where in the module declaration

I study Haskell and read a book, Learn You a Haskell for Great Good!

When an author talks about a keyword where, he says:

In imperative programming languages, you would solve this problem by storing the result of the calculation in a variable. In this section, you will learn how to use Haskells, where the keyword stores the results of intermediate calculations , which provides similar functionality.

However, I saw a keyword wherealso at the end of the module declaration, and I doubt the explanation of the “intermediate calculations” in this scenario, what is the meaning of what follows at the end of the module declaration?

+5
source share
3 answers
foo = baz
    where
    baz = 1
    quux = 2
    ...

For comparison:

module Foo 
    where
    baz = 1
    quux = 2
    ...

where . , , :

let baz = 1
    quux = 2
in module Foo

module Foo

(, ). , module ( ) ; . , . , ( , , -).

+3

, where . : .

+2

, , , .

module ModuleName (functions and datatypes to export) where

The brackets, which are optional, contain the names of the functions and data types that you want to use for the module user. Anything that is not specified between them will not be imported when the module is imported. If you decide to omit parentheses, all functions and data types will be exported.

+1
source

All Articles