Haskell Notes
This page is in draft!

Table of Contents


Section 1: Features of Haskell


Section 2: Lists

Operations

Texas Ranges

List Comprehension

Tuples


Section 3: Pattern Matching

Guards


where

IDIOM: make the helper functions in the where clause of a function


let


Case expressions


Section 4: Higher Order Functions

But sections don’t work with - since (-4) means negative 4. So we have to use (subtract 4)

flip' :: (a -> b -> c) -> (b -> a -> c)
flip' f = g
    where g x y = f y x

flip' :: (a -> b -> c) -> b -> a -> c
flip' f x y = f y x

Maps and Filters


Lambdas


Folds

foldl

foldr

foldl1 and foldr1

scanl and scanr


Function application

sum (map sqrt [1..130])
-- vs
sum $ map sqrt [1..130]

Function composition

(.) :: (b -> c) -> (a -> b) -> a -> c 
f . g = \x -> f (g x)  
map (\x -> negate (abs x)) [5,-3,-6,7,-3,2,-19,24]
-- vs
map (negate . abs) [5,-3,-6,7,-3,2,-19,24]

Section 5: Modules


Section 6: Algebraic data types


Record syntax


Type parameters


Derived instances

Examples


Type Synonyms