Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Successfully reported this slideshow.

Like this presentation? Why not share!

- Introduction to haskell by Luca Molteni 1463 views
- What is Pure Functional Programming... by Luca Molteni 1313 views
- Haskell for the Real World by Bryan O'Sullivan 5248 views
- Scaling Out With Hadoop And HBase by Age Mooij 7144 views
- Ocaml by Jackson dos Santo... 1410 views
- Using functional programming within... by Anil Madhavapeddy 1706 views

4,235 views

Published on

Slides of the workshop I gave at Devnology's Community Day.

No Downloads

Total views

4,235

On SlideShare

0

From Embeds

0

Number of Embeds

212

Shares

0

Downloads

86

Comments

0

Likes

2

No embeds

No notes for slide

- Paul Hudak: Yale

- John Hughes: Chalmers (G&#xF6;teborg)

- Simon Peyton Jones: Microsoft Cambridge

- Philp Wadler: Edinburgh

- exercises (1. Expressions, Values, and Types)

- warn about repeated variables

- one or more tests

- pattern

- exercises 4

- 1. An Introduction to Functional Programming using Haskell Michel Rijnders <mies@tty.nl>
- 2. Administrativia Anglais? tuple programming skill level working ghci handouts breaks
- 3. Main Features purely functional lazy higher order strongly typed general purpose
- 4. History September 1987 FPCA “design by committee” P. Hudak, J. Hughes, S. Peyton Jones, and P. Wadler: “A History of Haskell: Being Lazy With Class” (2007)
- 5. Main Difference mainstream languages are all about state functional programming is all about values
- 6. Computation all computation is done via the evaluation of EXPRESSIONS to yield VALUES every value has an associated TYPE
- 7. Types basic types: Char, Bool, Int, Integer, Double composite types lists: [Char], [Int], [[Char]] tuples: (String,Int)
- 8. Function Types square :: Integer -> Integer (&&) :: Bool -> Bool -> Bool length :: [a] -> Int (:) :: a -> [a] -> [a]
- 9. Function Deﬁnitions fac :: Int -> Int fac n = if n == 0 then 1 else n * fac (n - 1)
- 10. Guards -- guards fac’ :: Int -> Int fac’ n | n == 0 = 1 | otherwise = n * fac’ (n - 1)
- 11. Pattern Matching -- pattern matching fac’’ :: Int -> Int fac’’ 0 = 1 fac’’ n = n * fac’’ (n - 1)
- 12. Exercises Template -- file: Main.hs module Main where import Prelude hiding (sum,length) sum :: [Int] -> Int ... length :: [a] -> Int ...
- 13. List Patterns [] xs (x:xs) (x:_) (_:xs) (_:_)
- 14. List Comprehensions > let xs = [2,4,7] > [ 2 * x | x <- xs ] [4,8,14] > [ even x | x <- xs ] [True,True,False] > [ 2 * x | x <- xs, even x, x > 3] [8] > [ x + y | (x,y) <- [(2,3),(2,1)] ] [5,3] > [ x + y | (x,y) <- [(2,3),(2,1)], x < y ] [5]
- 15. Summary computation types functions guards pattern matching list comprehensions
- 16. Coming Up programming with lists higher-order functions type classes algebraic types
- 17. List Functions (:) :: a -> [a] -> [a] tail, init :: [a] -> [a] (++) :: [a] -> [a] -> [a] replicate :: Int -> a -> [a] (!!) :: [a] -> Int -> [a] take, drop :: concat :: [[a]] -> [a] Int -> [a] -> [a] length :: [a] -> Int splitAt :: Int -> [a] -> ([a],[a]) head, last :: [a] -> a
- 18. More List Functions repeat :: a -> [a] and, or :: [Bool] -> Bool reverse :: [a] -> [a] sum, product :: zip :: [Int] -> Int [a] -> [b] -> [(a,b)] [Float] -> Float unzip :: [(a,b)] -> ([a],[b])
- 19. Programming with Lists Prelude> :load Sprite *Sprite> print glider .#. ..# ### [(),(),()] *Sprite> print (flipH glider) ### ..# .#. [(),(),()]
- 20. Sprite.hs flipH :: Picture -> Picture flipH pic = reverse pic flipV :: Picture -> Picture flipV pic = [ reverse line | line <- pic ]
- 21. Higher Order Functions functions as arguments functions as results or both
- 22. Higher Order Functions patterns of computation mapping: transforming elements ﬁltering: selecting elements folding: combining elements
- 23. Mapping and Filtering map :: (a -> b) -> [a] -> [b] ﬁlter :: (a -> Bool) -> [a] -> [a] zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
- 24. Folding foldl :: (a -> b -> a) -> a -> [b] -> a foldl1 :: (a -> b -> a) -> [b] -> a foldr :: (a -> b -> b) -> b -> [a] -> b foldr1 :: (a -> a -> a) -> [a] -> a
- 25. Type Classes type class: a collection of of types over which certain functions are deﬁned equality class Eq (==) :: (Eq a) => a -> a -> Bool (/=) :: (Eq a) => a -> a -> Bool
- 26. Declaring a Class class Visible a where toString :: a -> String size :: a -> Int class Eq a where (==), (/=) :: a -> a -> Bool x /= y = not (x == y) x == y = not (x /= y)
- 27. Deﬁning an Instance instance Visible Char where toString ch = [ch] size _ = 1 instance Eq Bool where True == True = True False == False = True _ == _ = False
- 28. Derived Classes class Eq a => Ord a where (<), (<=), (>), (>=) :: a -> Bool max, min :: a -> a -> a compare :: a -> a -> Ordering
- 29. Built-In Classes Eq Ord Enum Show Read
- 30. Algebraic Types data Bool = False | True data Season = Spring | Summer | Autumn | Winter data Ordering = LT | EQ | GT
- 31. Product Types data People = Person Name Age type Name = String type Age = Int data Shape = Circle Double | Rectangle Float Float
- 32. Recursive Algebraic Types data Expr = Lit Int | Add Expr Expr | Sub Expr Expr data Tree a = Node (Tree a) (Tree a) | Leaf a
- 33. More? http://haskell.org/ G. Hutton: Programming in Haskell (Cambridge University Press) B. O’Sullivan, J. Goerzen, D. Stewart: Real World Haskell (O’Reilly)

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment