Hmm... Monad?
This is just a quick note while I was reading below articles.
Functor?
Functor f maps a concrete type to a concrete type(* -> *), and it defines fmap function. fmap : (a -> b) -> f a -> f b
class Functor f where
fmap :: (a -> b) -> f a -> f b
list as a functor.
It maps a concrete type a to a concrete type [a], and it defines fmap function.
instance Functor [] where
fmap = map
Maybe as a functor.
instance Functor Maybe where
fmap foo (Just x) = Just (foo x)
fmap foo Nothing = Nothing
Here, fmap: (a -> b) -> Maybe a -> Maybe b
Applicative Functor?
let a = fmap (*) [1,2,3,4]
-- a = [(1*),(2*),(3*),(4*)]
-- * is `int -> int -> int`. or `int -> (int -> int)`
fmap (\f -> f 9) a
-- results in [9, 18, 27, 36]