How to use the sanctuary-type-classes.ap 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 / par.js View on Github external
map(f) {
    return ap(Par.of(f), this)
  },
  // :: Par f a ~> Par f (a -> b) -> Par f b
github safareli / free / src / par.js View on Github external
const argT = foldArg(argF, f, T)
      if (fns.length === 0) {
        return argT
      }
      let fn = fns.pop()
      let res = ap(fn.f, argT)

      if (fn.length > 1) {
        fns.push(Fn(res, fn.length - 1))
        continue
      }

      while (fns.length > 0) {
        fn = fns.pop()
        res = ap(fn.f, res)
        if (fn.length > 1) {
          fns.push(Fn(res, fn.length - 1))
          break
        }
      }

      if (fns.length === 0) {
        return res
      }
    }
  },
  // :: Par f a ~> (Ɐ x. f x -> g x) -> Par g a
github fluture-js / Fluture / src / dispatchers / ap.js View on Github external
function ap$mval(mval, mfunc){
  if(!Z.Apply.test(mfunc)) throwInvalidArgument('Future.ap', 1, 'be an Apply', mfunc);
  return Z.ap(mval, mfunc);
}
github safareli / free / src / par.js View on Github external
if (Ap.is(argF)) {
        const lengthInitial = argsF.length
        while (Ap.is(argF)) {
          argsF.push(argF.x)
          argF = argF.f
        }
        fns.push(Fn(foldArg(argF, f, T), argsF.length - lengthInitial))
        continue
      }

      const argT = foldArg(argF, f, T)
      if (fns.length === 0) {
        return argT
      }
      let fn = fns.pop()
      let res = ap(fn.f, argT)

      if (fn.length > 1) {
        fns.push(Fn(res, fn.length - 1))
        continue
      }

      while (fns.length > 0) {
        fn = fns.pop()
        res = ap(fn.f, res)
        if (fn.length > 1) {
          fns.push(Fn(res, fn.length - 1))
          break
        }
      }

      if (fns.length === 0) {