haskell-lectures/VL2/content/VL2_define_functions1.tex
2015-04-20 00:51:14 +02:00

17 lines
746 B
TeX

Now you know how a regular function looks like, e.g:
\begin{haskellcode}
f :: Int -> Int
f x = x + 1
\end{haskellcode}
But now imagine we need a helper function which is very specific to the current function. In C we would have to define this new helper function at top-level and would probably make it \code{static}.
\pause
\vspace{\baselineskip}
\\
Haskell allows us to \textbf{inline} functions in a few more ways, e.g.:
\begin{itemizep}
\item with \code{where}
\item with \code{let...in}
\item anonymously (lambda abstraction)
\end{itemizep}
\slidep
A lot of Haskellers really dislike if you put non-generic functions at the top level. So you can still have atomic pieces, but inline the parts which are very specific to the current function.