Functor 函子

class Functor {
  constructor (val) {
    this.__val = val
  }

  map (fn) {
    return new Functor(fn(__this.value))
  }
}

即将范畴 Functor@val 通过 fn 映射为范畴 Function@fn(val)

Functor 本身具有 map 方法, 通过各种函数作为运算符, 映射成新的Functor

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×