You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
haskell/12-functors-applicative-fun...

19 lines
588 B

-- Functor:
-- :t (replicate 3)
(replicate 3) :: a -> [a]
-- :t fmap (replicate 3)
(fmap (replicate 3)) :: f a -> f [a]
-- We say that (replicate 3) has been "lifted" to f
-- Also think of functors as things that output values.
-- fmap'ing a functor is attaching a modifier to the output(s) of the functor
-- partial applications of a function are themselves functors
-- fmap'ing these partial applications results in composition!
-- Applicative functors - Applicative class in Haskell
class (Functor f) => Applicative f where
pure :: a -> f a
(<*>) :: f (a -> b) -> (f a -> f b)