# Merkzettel
# Haskell
## good to know functions
- `flip`
- `map`
- `filter`
- `foldr`
- `foldl`
- `++`
- `!!`
- `head`
- `tail`
- `last`
- `init`
- `elem`
- `null`
- `length`
- `reverse`
- `iterate`
- `repeat`
- `replicate`
- `cycle`
- `take`
- `drop`
- `splitAt`
- `zip`
- `zipWith`
-
## Types
### Type Synonyms
```
type Age = Int
type PatientName = (String, String)
firstName :: ParientName -> String
firstName patient = fst patient
```
### Actual New Types
```
data Sex = Male | Female
data RhType = Pos | Neg
data ABOType = A | B | AB | O -- A is a 0-Argument Constructor
data BloodType = BloodType ABOType RhType
data Shape = Circle Double
| Rectangle Double Double
```
create functions with pattern matching
### Type Classes
#### Declaring Type Classes
```
class Describable a where
describe :: a -> String
--Inheritance:
class Eq a => Ord a where
(<) :: a -> a -> Bool
...
somefunc :: (Ord a, Enum a) => a -> a
somefunc param = ...
```
#### Implementing them
```
instance Show Shape where
show (Circle r) = "C" ++ (show r)
show (Rectangle a b) = "R" ++ (show a) ++ "/" ++ (show b)
```
# \\-Kalkül
- `(\x.x)y != \x.x y == \x.(x y)`
### Alpha Äquivalenz:
Ineinandere Überführung durch Umbenennung der Variablen
### Eta Äquivalenz: