UNPKG

moy-fp

Version:
23 lines (18 loc) 520 B
import curry from '../Function/curry' // simple internal Functor Identity // you can also use external Identity to implement set, but it const more performance const Identity = a => ({ value: a, map(f){ return Identity(f(this.value)) }, }) // here we just use .value, and not use extract or Comonad, assue it has no side effects /** * Lens s a -> a -> s -> s * Lens s a = Functor f => (a -> f a) -> s -> f s */ const set = curry( (Lens, v, a) => Lens(() => Identity(v))(a).value ) export default set