Slide 1

Slide 1 text

Introduction to Haskell and its REPL

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

$ docker run -it --rm \ mitchty/alpine-ghc ghci 1.

Slide 4

Slide 4 text

$ docker run -it --rm \ mitchty/alpine-ghc ghci docker pull mitchty/alpine-ghc:latest 1.

Slide 5

Slide 5 text

▪ 1 + 2 ▪ 2^1000 ▪ (+) 1 2 ▪ :t (+) ▪ :i (+) So... what now?

Slide 6

Slide 6 text

▪ (+) :: a -> a -> a Functions Everywhere

Slide 7

Slide 7 text

▪ [1, 2, 3] ▪ [1..] ▪ [1..10] ▪ [1, 1.25 .. 4.0] List

Slide 8

Slide 8 text

▪ (:) :: a -> [a] -> [a] ▪ (++) :: [a] -> [a] -> [a] List

Slide 9

Slide 9 text

▪ head :: [a] -> a ▪ tail :: [a] -> [a] ▪ take :: Int -> [a] -> [a] ▪ drop :: Int -> [a] -> [a] List

Slide 10

Slide 10 text

▪ map :: (a -> b) -> [a] -> [b] ▪ filter :: (a -> Bool) -> [a] -> [a] List

Slide 11

Slide 11 text

▪ :t ← type inspection ▪ :i ← info ▪ :l ← load .hs file ▪ :r ← reload files GHCi

Slide 12

Slide 12 text

BYO Editor ▪ Spacemacs http://spacemacs.org/ ▪ Atom https://atom.io/ ▪ Visual Studio https://code.visualstudio.com/

Slide 13

Slide 13 text

$ docker run -it --rm \ -v `pwd`:/root \ mitchty/alpine-ghc ghci 2.

Slide 14

Slide 14 text

Wanna try an exercise together? Let’s reverse a list

Slide 15

Slide 15 text

Theorems for free! – Philip Walder, 1989 https://people.mpi-sws.org/~dreyer/tor/papers/wadler.pdf

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Thanks! Any questions? @filippovitale