0
Welcome



woensdag 27 januari 2010
Haskell
                            Chris Eidhof




woensdag 27 januari 2010
Three things


                    • Strong types
                    • Purity
                    • Larger example


woen...
Strong Types

                    • As programmers, we do a lot of testing:
                    • * Unit Testing
         ...
Strong Types


                    • Can we automate testing?



woensdag 27 januari 2010
List
                             Type-parameter
                                                   Constructor



       ...
List Example


                             Example: List.hs




woensdag 27 januari 2010
Functions
                           Give me a list of a And I’ll return a
                                               ...
Purity



             •             State = Evil


woensdag 27 januari 2010
Purity

             •               Same Input
             •         ntial
                Refere cy
               Tran...
Purity

                    • No side effects:
                    • * Variables
                    • * I/O
             ...
Example


                    •      sort :: [Int] -> [Int]


                     How do we know sort doesn’t launch miss...
Doing I/O


                    •      putStr :: String -> IO ()


                            The IO type shows us it’s n...
Laziness


                    •      if (x < 10 && x > 5)



                    •      Example: Lazy.hs




woensdag 27 ...
Quickcheck


                    • Automatic testing of pure code.

                               Example: Reverse.hs


w...
Software
                           Transactional
                              Memory

                    • Composable t...
Fusion



•   myFunction = map square . map toInt

•                          = map (square . toInt)


woensdag 27 januari...
Parallel code


                    •      map    :: (a -> b) -> [a] -> [b]

                    •      parMap :: (a -> b)...
Effects
                            Useful
                                         Most            Nirvana
              ...
Arc Challenge
                    •      Write a program that causes the url said (e.g. http://
                          ...
Arc Challenge
                    • Solution in Arc:
                    •      (defop said req

                         ...
Arc Challenge


       arc = do name <- input
               link "click here"
               display $ "you said:" ++ nam...
Arc Challenge (2)
                              input uses type-inference!

             arc2 = do  name  <- input
       ...
Read more
• Real World Haskell - http://book.realworldhaskell.org/
• Haskell.org - http://haskell.org
• Haskell Café - htt...
Getting Started

                    • 1. Install the Haskell Platform
                    • http://hackage.haskell.org/pl...
Keep in touch


                    • http://github.com/chriseidhof
                    • @chriseidhof


woensdag 27 janua...
One more thing...




woensdag 27 januari 2010
Have fun



woensdag 27 januari 2010
Upcoming SlideShare
Loading in...5
×

HN NL - Haskell

645

Published on

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
645
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "HN NL - Haskell"

  1. 1. Welcome woensdag 27 januari 2010
  2. 2. Haskell Chris Eidhof woensdag 27 januari 2010
  3. 3. Three things • Strong types • Purity • Larger example woensdag 27 januari 2010
  4. 4. Strong Types • As programmers, we do a lot of testing: • * Unit Testing • * Debugging • * Specification woensdag 27 januari 2010
  5. 5. Strong Types • Can we automate testing? woensdag 27 januari 2010
  6. 6. List Type-parameter Constructor • data [a] = [] | a : [a] Type Constructor woensdag 27 januari 2010
  7. 7. List Example Example: List.hs woensdag 27 januari 2010
  8. 8. Functions Give me a list of a And I’ll return a list of a • reverse :: [a] -> [a] • reverse [] = [] • reverse (x:xs) = reverse xs ++ [x] Pattern Matching Example: Reverse.hs woensdag 27 januari 2010
  9. 9. Purity • State = Evil woensdag 27 januari 2010
  10. 10. Purity • Same Input • ntial Refere cy Transp aren = • Same output woensdag 27 januari 2010
  11. 11. Purity • No side effects: • * Variables • * I/O • * launchMissiles() woensdag 27 januari 2010
  12. 12. Example • sort :: [Int] -> [Int] How do we know sort doesn’t launch missiles? woensdag 27 januari 2010
  13. 13. Doing I/O • putStr :: String -> IO () The IO type shows us it’s not pure woensdag 27 januari 2010
  14. 14. Laziness • if (x < 10 && x > 5) • Example: Lazy.hs woensdag 27 januari 2010
  15. 15. Quickcheck • Automatic testing of pure code. Example: Reverse.hs woensdag 27 januari 2010
  16. 16. Software Transactional Memory • Composable transactions • No deadlocks! woensdag 27 januari 2010
  17. 17. Fusion • myFunction = map square . map toInt • = map (square . toInt) woensdag 27 januari 2010
  18. 18. Parallel code • map  :: (a -> b) -> [a] -> [b] • parMap :: (a -> b) -> [a] -> [b] woensdag 27 januari 2010
  19. 19. Effects Useful Most Nirvana languages Haskell Useless Dangerous Safe Simon Peyton-Jones, Caging The Effects Monster woensdag 27 januari 2010
  20. 20. Arc Challenge • Write a program that causes the url said (e.g. http:// localhost:port/said) to produce a page with an input field and a submit button. When the submit button is pressed, that should produce a second page with a single link saying "click here." When that is clicked it should lead to a third page that says "you said: ..." where ... is whatever the user typed in the original input field. The third page must only show what the user actually typed. I.e. the value entered in the input field must not be passed in the url, or it would be possible to change the behavior of the final page by editing the url. woensdag 27 januari 2010
  21. 21. Arc Challenge • Solution in Arc: • (defop said req (aform [onlink "click here" (pr "you said: " (arg _ "foo"))] (input "foo") (submit))) • woensdag 27 januari 2010
  22. 22. Arc Challenge arc = do name <- input           link "click here"           display $ "you said:" ++ name See gist: http://gist.github.com/260052 woensdag 27 januari 2010
  23. 23. Arc Challenge (2) input uses type-inference! arc2 = do  name  <- input            (x,y) <- input            link "click here"            display (add x y)            display ("you said:" ++ name) woensdag 27 januari 2010
  24. 24. Read more • Real World Haskell - http://book.realworldhaskell.org/ • Haskell.org - http://haskell.org • Haskell Café - http://haskell.org/haskellwiki/Mailing_lists • Planet Haskell - http://planet.haskell.org/ • Haskell reddit - http://haskell.reddit.com • woensdag 27 januari 2010
  25. 25. Getting Started • 1. Install the Haskell Platform • http://hackage.haskell.org/platform/ • 2. Haskell in 10 minutes • http://haskell.org/haskellwiki/ Learn_Haskell_in_10_minutes woensdag 27 januari 2010
  26. 26. Keep in touch • http://github.com/chriseidhof • @chriseidhof woensdag 27 januari 2010
  27. 27. One more thing... woensdag 27 januari 2010
  28. 28. Have fun woensdag 27 januari 2010
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×