Your SlideShare is downloading. ×
0
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Haskell @ HAN Arnhem 2013-2014
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Haskell @ HAN Arnhem 2013-2014

322

Published on

These are cherry-picked slides from Simon Peyton Jones' excellent tutorial on Haskell at http://research.microsoft.com/en-us/um/people/simonpj/papers/haskell-tutorial/index.htm …

These are cherry-picked slides from Simon Peyton Jones' excellent tutorial on Haskell at http://research.microsoft.com/en-us/um/people/simonpj/papers/haskell-tutorial/index.htm

I prepared these for a guest lecture at the Hogeschool Arnhem-Nijmegen.

If this piqued your interest, please have a look at SPJ's video's at the above link!

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

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

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • I stole most of the slidesfromSPJ’s excellent ‘A taste of Haskell’ introduction, so a lot of credit goestohim.
  • Examples?Why not obvious? (side effects, purity, laziness)
  • Databases : Haskell Database Connectivity
  • new term: alt-shift-enterLayout modes: alt-spaceKill window: alt-shift-cMove focus: alt-j, alt-kglxgears
  • FFI = Foreignfunction interface
  • Implement ‘insert’ later togetherwith the whole class.
  • How do you guys think you can test Haskell programs?
  • DEMO> import Test.QuickCheck
  • Why might that do arbitrary stateful things?
  • () = unit, lege tuple“Actions” sometimes called “computations”An action is a first class valueEvaluating an action has no effect; performing the action has an effect
  • () = unit, lege tuple“Actions” sometimes called “computations”An action is a first class valueEvaluating an action has no effect; performing the action has an effect
  • Plan ACode contracts, spec#By using parallel concepts (reactive extensions, linq), the need for better control over effects becomes greater (atomic actions)Plan BSelectively allow side effects (monads, e.g. IO)
  • Do Euler 1 andmaybe 2 togetherwith the whole class.
  • Transcript

    • 1. Haskell Tjeerd Hans Terpstra Microsoft Consultant Atos
    • 2. Agenda • Introduction • History of Haskell • Real world Haskell • I/O • Step back • Project Euler
    • 3. Introduction – who? • Microsoft Consultant @ Atos • Microsoft Competence Leader for Atos East NL • Developer, Team lead, Scrum Master @tjeerdhans
    • 4. Introduction – who too? Simon Peyton Jones Researcher at Microsoft Research (Cambridge, England) http://research.microsoft.com/en-us/people/simonpj/ • A Taste of Haskell - http://research.microsoft.com/enus/um/people/simonpj/papers/haskell-tutorial/index.htm
    • 5. Introduction – what? • Haskell is a programming language that is • • • • • purely functional lazy higher order strongly typed general purpose
    • 6. Introduction – why? • Functional programming will make you think differently about programming • Mainstream languages are all about state • Functional programming is all about values • Whether or not you drink the Haskell whisky, you'll be a better programmer in whatever language you regularly use.
    • 7. History of Haskell
    • 8. History of Haskell
    • 9. History of Haskell 3
    • 10. History of Haskell 4
    • 11. © xkcd http://xkcd.com/1312/ Real world Haskell
    • 12. Real world Haskell • Text-based tools • Imperative input/output programming • Parsing, transforming data • GUI programming • Event driven programming • Hook up events to callback functions in Haskell • Database programming • Network programming • Examples: http://book.realworldhaskell.org/read
    • 13. Real world Haskell – xmonad • xmonad is an X11 tiling window manager written entirely in Haskell … xmo..-wut?! DEMO!
    • 14. Real world Haskell – xmonad • xmonad is an X11 tiling window manager written entirely in Haskell
    • 15. Why xmonad? • Because it's • • • • • A real program of manageable size that illustrates many Haskell programming techniques is open-source software is being actively developed by an active community
    • 16. Manageable size Code metacity ion3 Comments Language >50000 C 20000 700 C larswm 6000 130 C wmii 6000 100 C dwm 4.2 1500 200 C 500 700 Haskell xmonad 0.2
    • 17. Inside xmonad
    • 18. Things to notice • Purity makes the interface explicit • Takes a stack, and returns a stack; that is all • Takes a stack; may modify it; may modify other persistent state; may do I/O
    • 19. I/O
    • 20. Where’s the I/O in xmonad? • All this pure stuff is nice, but sooner or later we have to: • Talk to X11, whose interface is not at all pure • Do input/output (other programs)
    • 21. Doing I/O • Idea: • But: now might do arbitrary stateful things  • And what does this do? • What order are the things printed? • Are they printed at all? Order of evaluation! Laziness!
    • 22. The main idea A value of type (IO t) is an “action” that, when performed, may do some input/output before delivering a result of type t
    • 23. A helpful picture A value of type (IO t) is an “action” that, when performed, may do some input/output before delivering a result of type t
    • 24. Simple I/O getLine :: IO String putStr :: String -> IO () Main program is an action of type IO () main :: IO () Main = putStr “Hello World”
    • 25. Connecting actions up Goal: read a line and then write it back out
    • 26. Connecting actions up We have connected two actions to make a new, bigger action.
    • 27. Getting two lines We want to just return (s1,s2)
    • 28. The return combinator
    • 29. Taking a step back The central challenge
    • 30. The challenge of effects
    • 31. Project Euler http://projecteuler.net
    • 32. Thanks

    ×