distums / distums.github.io

my personal blog
https://distums.github.io/
0 stars 0 forks source link

Functor #33

Open distums opened 6 years ago

distums commented 6 years ago

definition from fantasy-land

  1. u.map(a => a) is equivalent to u (identity)
  2. u.map(x => f(g(x))) is equivalent to u.map(g).map(f) (composition)

map method

map :: Functor f => f a ~> (a -> b) -> f b

A value which has a Functor must provide a map method. The map method takes one argument:

u.map(f)
  1. f must be a function,
distums commented 6 years ago

Functor是一个容器,对于Functor,非常重要的一点是弄清它所包装的值