Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Beginner's Hands-On with Haskell

Beginner's Hands-On with Haskell

An interactive workshop for newcomers to Haskell and functional programming. Led at the Louisville Haskell Meetup

Shane Logsdon

May 10, 2016
Tweet

More Decks by Shane Logsdon

Other Decks in Programming

Transcript

  1. Haskell Basics A Workshop-ish Thing

  2. Tools

  3. stack • Bundles useful tools • Simplifies getting started

  4. ghci • GHC’s REPL • Commands are vim-like • See

    what’s available with `:help`
  5. FP Principles

  6. First-Class Functions • Functions are values • JS: var add1

    = function (a) { return a + 1; }; • HS: let add1 = \a -> a + 1
  7. Higher-Order Functions • Functions can be passed to other functions

    • JS: [1,2,3].map(add1); • HS: map add1 [1,2,3]
  8. Composition • Small functions can be composed into big functions

    • let adder = \a b -> a + b • let add1 = \a -> adder a 1 • Partial application • let add2 = adder 2
  9. (Im)Purity • Referential Transparency: – f(‘a’) will always be ‘b’

    • Effects: – we can't control the world, so let's describe how it will change
  10. Laziness • All data isn’t needed all of the time

    • head [1..]