klequis / zz-haskell-notebook

Notes from learning Haskell
1 stars 0 forks source link

Scope #37

Open klequis opened 2 years ago

klequis commented 2 years ago

A scope is where a variable can be validly referred to by name in a program. Something of global scope can be referred to anywhere in the entire program itself. A declaration at the top level of a Haskell module has module scope, and anything in that same module can refer to it. Another word used with the same meaning is visibility, because if a variable isn’t visible, then it’s not in scope and cannot be referenced by name.

Scope within a Haskell module is determined by indentation which determines nesting. A definition that is not indented is called "top-level" and is available to code that imports the module.