HaskellWiki

Haskell | Wiki community | Recent changes
Random page | Special pages

 

Not logged in
Log in | Help

Variable

Categories: Glossary | Language

In Haskell, a variable is a name for some valid expression. The word "variable" as applied to Haskell variables is misleading, since a given variable's value never varies during a program's runtime. Instead, the concept is much closer to the mathematical sense of the word, where one might use pi to stand for 3.14159..., or X2 to represent the formula to compute to test for goodness of fit. These values do not generally change in the middle of performing a mathematical calculation or proof.

The operator = is used to assign a value to a variable, e.g. phi = 1.618. The scope of such variables can be controlled by using let or where clauses.

Another sense in which "variable" is used in Haskell is as formal parameters to a function. For example:

add x y = x + y

x and y are formal parameters for the add function. This corresponds to the notion of "variable" in the lambda calculus.

Retrieved from "http://haskell.org/haskellwiki/Variable"

This page has been accessed 903 times. This page was last modified 00:15, 11 October 2006. Recent content is available under a simple permissive license.