|
- These look almost the same, but they are different constructs. \code{where} is bound to the pattern matching \code{f x =} and may also have access to parts of a function that are not syntactically expressions, e.g.:
- \begin{haskellcode}
- f x
- | cond1 x = a
- | cond2 x = g a
- | otherwise = f (h x a)
- where
- a = w x
- \end{haskellcode}
- While that is not possible with \code{let}, which is an actual expression and can be used whenever expressions are allowed (e.g. inside \emph{Monads}, we'll know more about these in a few weeks).
- \vspace{\baselineskip}
- \\
- There are a few more intricacies, but most of the time this is just style consideration:\\ \url{https://wiki.haskell.org/Let_vs._Where}
- \pause
- \vspace{\baselineskip}
- \\
- How would we have to rewrite the function in order to use \code{let}?
|