How to use the sanctuary-type-classes.map function in sanctuary-type-classes

To help you get started, we’ve selected a few sanctuary-type-classes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github safareli / free / src / concurrent.js View on Github external
map(f) {
    return Seq(map(f, this.seq()))
  },
  // :: Concurrent f a ~> Concurrent f (a -> b) -> Concurrent f b
github safareli / free / src / seq.js View on Github external
const fn = stack.pop()
        focus = fn(focus.a)
      }
      if (Pure.is(focus)) {
        return of(T, done(focus.a))
      }
      while (Roll.is(focus)) {
        // We are mutating `stack` for performance reasons but it's not
        // an issue as it's not an observable side effects 8-)
        // If we wanted to do same in a staticly typed language,
        // some kind of efficient type aligned sequnce should be used.
        stack.push(focus.y)
        focus = focus.x
      }
      // here `focus` must be `Lift`
      return map((v) => {
        if (stack.length === 0) {
          return done(v)
        }
        const fn = stack.pop()
        const nextFocus = fn(v)
        return next({ focus: nextFocus, stack })
      }, f(focus.i))
    }, { focus: this, stack: [] })
  },
github sanctuary-js / sanctuary / test / internal / List.js View on Github external
List.prototype[FL.ap] = function(other) {
  return this.isNil || other.isNil ?
    Nil :
    Z.concat (Z.map (other.head, this), Z.ap (other.tail, this));
};
github sanctuary-js / sanctuary / test / internal / List.js View on Github external
List.prototype[FL.traverse] = function(typeRep, f) {
  return this.isNil ?
    Z.of (typeRep, Nil) :
    Z.ap (Z.map (Cons, f (this.head)), Z.traverse (typeRep, f, this.tail));
};
github sanctuary-js / sanctuary / test / internal / List.js View on Github external
List.prototype[FL.map] = function(f) {
  return this.isNil ?
    Nil :
    Cons (f (this.head)) (Z.map (f, this.tail));
};
github fluture-js / Fluture / src / dispatchers / map.js View on Github external
function map$mapper(mapper, m){
  if(!Z.Functor.test(m)) throwInvalidArgument('Future.map', 1, 'be a Functor', m);
  return Z.map(mapper, m);
}
github fabioluz / fun-js / src / fun.js View on Github external
S.lift4 = S.curry4 ((fn, a1, a2, a3, a4) => Z.ap (Z.ap (Z.ap (Z.map (fn, a1), a2), a3), a4));
S.eitherToFuture = S.either (Future.reject) (Future.of);
github safareli / free / src / concurrent.js View on Github external
    return chain(f => map(f, this), mf)
  },
github safareli / free / src / seq.js View on Github external
    return chain(f => map(f, this), mf)
  },