5. Everything is a function
• No “assignment”
• Referential transparancy
• Partial application, no parentheses needed
a=5
a=6 -- Invalid!
squares xs = map (λx → x ∗ x) xs
6. Why should I learn Haskell?
• Functional Programming gives you a fresh way to look at
problems
• Even if you don’t use a functional language
• Python, Ruby, C# all use ideas from FP
• Google’s Map/Reduce and Hadoop are large scale FP
8. Some standard functions
sum [ ] =0
sum (x : xs) = x + sum xs
product [ ] =1
product (x : xs) = x ∗ product xs
and [ ] = True
and (x : xs) = x ∧ and xs
9. Everything is a fold!
foldr (⊕) e [ ] =e
foldr (⊕) e (x : xs) = x ⊕ (foldr (⊕) e xs)
sum = foldr ( + ) 0
product = foldr ( ∗ ) 1
and = foldr ( ∧ ) True
13. What we didn’t tell you
• Function composition
• Types
• Purity and I/O
• Monads
• Foreign Function Interface
• ...
14. Haskell in the Real World
• Large applications (XMonad, Darcs, GHC, Yi)
• Lots of libraries (Today on hackage: 814 libraries and
programs)
• Used by large companies (Credit Suisse, Galois, Microsoft,
ABN Amro . . . )
• Lots of ways to learn Haskell ((free) textbooks, university
courses, haskell wiki, blogs)
15. Functional programming
• ... sharpens your brain
• ... is lots of fun
• ... can help you become a better programmer