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

Introduction to Haskell and its REPL

Introduction to Haskell and its REPL

Brief and gentle introduction to Haskell and its REPL

Filippo Vitale

July 27, 2017
Tweet

More Decks by Filippo Vitale

Other Decks in Programming

Transcript

  1. ▪ 1 + 2 ▪ 2^1000 ▪ (+) 1 2

    ▪ :t (+) ▪ :i (+) So... what now?
  2. ▪ (:) :: a -> [a] -> [a] ▪ (++)

    :: [a] -> [a] -> [a] List
  3. ▪ head :: [a] -> a ▪ tail :: [a]

    -> [a] ▪ take :: Int -> [a] -> [a] ▪ drop :: Int -> [a] -> [a] List
  4. ▪ map :: (a -> b) -> [a] -> [b]

    ▪ filter :: (a -> Bool) -> [a] -> [a] List
  5. ▪ :t <espression> ← type inspection ▪ :i <espression> ←

    info ▪ :l <filename> ← load .hs file ▪ :r ← reload files GHCi
  6. ▪ foo :: a -> a ▪ foo2 :: b

    -> a ▪ foo3 :: a -> b -> a What’s the only possible implementation of `foo`?