Personal tools

Weak head normal form

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
(New page: An expression is in weak head normal form, iff it is either: * a constructor (eventually applied to arguments) like True, Just (square 42) or (:) 1 * a built-in function applied to too few...)
Current revision (23:47, 25 December 2012) (edit) (undo)
m (added abbreviation WHNF)
 
(2 intermediate revisions not shown.)
Line 1: Line 1:
-
An expression is in weak head normal form, iff it is either:
+
An expression is in weak head normal form (WHNF), if it is either:
* a constructor (eventually applied to arguments) like True, Just (square 42) or (:) 1
* a constructor (eventually applied to arguments) like True, Just (square 42) or (:) 1
* a built-in function applied to too few arguments (perhaps none) like (+) 2 or sqrt.
* a built-in function applied to too few arguments (perhaps none) like (+) 2 or sqrt.
* or a lambda abstraction \x -> expression.
* or a lambda abstraction \x -> expression.
 +
Note that the arguments do not themselves have to be fully evaluated for an expression to be in weak head normal form; thus, while (square 42) can be reduced to (42 * 42), which can itself be reduced to a normal form of 1764, Just (square 42) is WHNF without further evaluation. Similarly, (+) (2 * 3 * 4) is WHNF, even though (2 * 3 * 4) could be reduced to the normal form 24.
== See also ==
== See also ==

Current revision

An expression is in weak head normal form (WHNF), if it is either:

  • a constructor (eventually applied to arguments) like True, Just (square 42) or (:) 1
  • a built-in function applied to too few arguments (perhaps none) like (+) 2 or sqrt.
  • or a lambda abstraction \x -> expression.

Note that the arguments do not themselves have to be fully evaluated for an expression to be in weak head normal form; thus, while (square 42) can be reduced to (42 * 42), which can itself be reduced to a normal form of 1764, Just (square 42) is WHNF without further evaluation. Similarly, (+) (2 * 3 * 4) is WHNF, even though (2 * 3 * 4) could be reduced to the normal form 24.

See also