There are two ways to do this:
foo a = b where b = a * 2 foo a = let b = a * 2 in b
In most cases, the choice between them is aesthetic rather than technical. More precisely, where
can only be bound to definitions, while let ... in ...
can be used wherever an expression is allowed. Both where
and let
introduce blocks, which makes several internal variables convenient in both cases.
source share