mirror of
https://github.com/janishutz/eth-summaries.git
synced 2026-03-14 10:50:05 +01:00
[FMFP] Start summary
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
Haskell is a functional programming language. As such, its functions can be thought of as being similar to mathematical functions and as such are side-effect-free.
|
||||
|
||||
Haskell's type system is very robust and an interesting topic to learn about.
|
||||
The basic data types you already know from other programming languages are also present here. This includes all primitives like integers, floating point numbers, chars and booleans.
|
||||
|
||||
Strings are handled similarly to how \texttt{C} does it, in that strings are char arrays.
|
||||
|
||||
Arrays however are dynamic length in Haskell as opposed to many other statically typed programming languages.
|
||||
|
||||
Since Haskell is an imperative language (i.e. you describe \textit{what} you want achieve)
|
||||
as opposed to a declarative language (i.e. you describe \textit{how} you achieve what you want to achieve), there are no loops in Haskell,
|
||||
as loops don't appear in mathematical formulas and functions either.
|
||||
What we can do however is recursion and this is the main way of doing iterative work in Haskell.
|
||||
|
||||
Additionally, Haskell features \textit{lazy evaluation} (i.e. statements are evaluated only as needed) as opposed to \textit{eager evaluation} (i.e. statemetns are evaluated immediately).
|
||||
|
||||
In this course the \texttt{Glasgow Haskell Compiler}, short \texttt{ghc} is used. Installation is really easy (as long as you're on Linux)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
\subsection{The bad news: The syntax}
|
||||
In short: It's quite bad, but you will get used to it and some of the (arguably) poor looking syntax choices will start to make more sense.
|
||||
|
||||
You should use 2 space indents (yuck) and indents matter, just like in Python.
|
||||
|
||||
We can use binary functions in infix or prefix notation, i.e. \texttt{x `mod` z} and \texttt{mod x z} are equivalent.
|
||||
|
||||
For integers the following functions are available: Normal arithmetic operations \texttt{+, -, *, /, mod, abs}, as well as \texttt{\^} which is used for exponentiation.
|
||||
|
||||
To use prefix notation on non-alphanumeric function names, wrap them in parenthesis like this: \texttt{(+) x z}. Using \texttt{+ x z} does not work.
|
||||
|
||||
We can use the normal comparison operators that return a boolean on evaluation. \bi{Booleans} are \texttt{True} and \texttt{False}
|
||||
|
||||
0
semester4/fmfp/parts/00_haskell/02_evalutation.tex
Normal file
0
semester4/fmfp/parts/00_haskell/02_evalutation.tex
Normal file
Reference in New Issue
Block a user