How to use the sanctuary-type-classes.of 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 / seq.js View on Github external
return chainRec(T, (next, done, { focus, stack }) => {
      while (Pure.is(focus) && stack.length) {
        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)
github fluture-js / Fluture / test / unit / 5.par.js View on Github external
test('of resolves with the value', function (){
  var m = Z.of(Par, 1);
  return assertResolved(seq(m), 1);
});
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 safareli / free / src / par.js View on Github external
const foldArg = (node, f, T) => {
  if (Pure.is(node)) {
    return of(T, node.x)
  } else if (Lift.is(node)) {
    return f(node.i)
  }
}
github safareli / free / src / seq.js View on Github external
    return chain(a => of(Seq, f(a)), this)
  },
github safareli / free / src / seq.js View on Github external
    ({ done, value }) => done ? of(Seq, value) : chainRec(Seq, f, value),
    f(chainRecNext, chainRecDone, i)