A day with pure functions

42 :: Int
02

Functions

map :: (a -> b) -> [a] -> [b]
filter :: (a -> Bool) -> [a] -> [a]
foldr :: (a -> b -> b) -> b -> [a] -> b
zip :: [a] -> [b] -> [(a,b)]
compose :: (b -> c) -> (a -> b) -> a -> c
03

Type Classes

Functor

class Functor f where
  fmap :: (a -> b) -> f a -> f b

fmap id = id

fmap (f . g) = fmap f . fmap g

Applicative

class Functor f => Applicative f where
  pure :: a -> f a
  (<*>) :: f (a -> b) -> f a -> f b

Monad

class Applicative m => Monad m where
  (>>=) :: m a -> (a -> m b) -> m b
  return :: a -> m a
λ @ λ λ @ x y a b
04

Composition

value
Input
>>=
Functor
fmap
<*>
Applicative
pure
>>=
Monad
bind
->
result
Output
05

IO & The World

main :: IO () main = putStrLn "Hello, haskell.day"