How to use the fantasy-land.concat function in fantasy-land

To help you get started, we’ve selected a few fantasy-land 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 sanctuary-js / sanctuary-type-classes / test / Sum.js View on Github external
//  Sum :: Number -> Sum
function Sum(value) {
  if (!(this instanceof Sum)) return new Sum (value);
  this.value = value;
}

Sum[FL.empty] = function() { return Sum (0); };

Sum.prototype['@@type'] = 'sanctuary-type-classes/Sum@1';

Sum.prototype[FL.equals] = function(other) {
  return Z.equals (this.value, other.value);
};

Sum.prototype[FL.concat] = function(other) {
  return Sum (this.value + other.value);
};

Sum.prototype[FL.invert] = function() {
  return Sum (-this.value);
};

Sum.prototype.inspect =
Sum.prototype['@@show'] = function() {
  return 'Sum (' + show (this.value) + ')';
};

module.exports = Sum;
github dustinws / zoom / src / validation.js View on Github external
Validation.prototype[fl.of] = Validation.prototype.of;

// Validation Chain
Validation[fl.chain] = Validation.chain;
Validation.prototype[fl.chain] = Validation.prototype.chain;

// Validation Functor
Validation[fl.map] = Validation.map;
Validation.prototype[fl.map] = Validation.prototype.map;

// Validation Apply
Validation[fl.ap] = Validation.ap;
Validation.prototype[fl.ap] = Validation.prototype.ap;

// Validation Semigroup
Validation[fl.concat] = Validation.concat;
Validation.prototype[fl.concat] = Validation.prototype.concat;

// Validation Monoid
Validation[fl.empty] = Validation.empty;
Validation.prototype[fl.empty] = Validation.prototype.empty;


// Success Applicative
Validation.Success[fl.of] = Validation.Success.of;
Validation.Success.prototype[fl.of] = Validation.Success.prototype.of;

// Failure Applicative
Validation.Failure[fl.of] = Validation.Failure.of;
Validation.Failure.prototype[fl.of] = Validation.Failure.prototype.of;
github dustinws / zoom / src / remote-data.js View on Github external
// RemoteData Chain
RemoteData[FL.chain] = RemoteData.chain;
RemoteData.prototype[FL.chain] = RemoteData.prototype.chain;

// RemoteData Functor
RemoteData[FL.map] = RemoteData.map;
RemoteData.prototype[FL.map] = RemoteData.prototype.map;

// RemoteData Apply
RemoteData[FL.ap] = RemoteData.ap;
RemoteData.prototype[FL.ap] = RemoteData.prototype.ap;

// RemoteData Semigroup
RemoteData[FL.concat] = RemoteData.concat;
RemoteData.prototype[FL.concat] = RemoteData.prototype.concat;


module.exports = RemoteData;
github dustinws / zoom / src / packages / validation / index.js View on Github external
Validation.Failure.prototype[FL.of] = Validation.Failure.prototype.of;

// Failure Chain
Validation.Failure[FL.chain] = Validation.Failure.chain;
Validation.Failure.prototype[FL.chain] = Validation.Failure.prototype.chain;

// Failure Functor
Validation.Failure[FL.map] = Validation.Failure.map;
Validation.Failure.prototype[FL.map] = Validation.Failure.prototype.map;

// Failure Apply
Validation.Failure[FL.ap] = Validation.Failure.ap;
Validation.Failure.prototype[FL.ap] = Validation.Failure.prototype.ap;

// Failure Semigroup
Validation.Failure[FL.concat] = Validation.Failure.concat;
Validation.Failure.prototype[FL.concat] = Validation.Failure.prototype.concat;


export default Validation;
github jongold / further / src / index.js View on Github external
// .of :: Applicative a -> Style a
Style.prototype.of = function(a) {
  return new Style(() => a);
};
Style.of = Style.prototype.of;
Style.prototype[fl.of] = Style.prototype.of;
Style[fl.of] = Style.of;

// #concat :: Semigroup Style => Style ~> Style -> Style
Style.prototype.concat = function(a) {
  return new Style(props => {
    return { ...this.resolve(props), ...a.resolve(props) };
  });
};
Style.prototype[fl.concat] = Style.prototype.concat;

// .empty :: Monoid Style => () -> Style
Style.prototype.empty = () => Style.of({});
Style.empty = Style.prototype.empty;
Style.prototype[fl.empty] = Style.prototype.empty;
Style[fl.empty] = Style.empty;

// #map :: Functor Style => Style a ~> (a -> b) -> Style b
Style.prototype.map = function(f) {
  return new Style(props => {
    return f(this.resolve(props));
  });
};
Style.prototype[fl.map] = Style.prototype.map;

// chain :: Chain Style => Style a ~> (a -> Style b) -> Style b
github dustinws / zoom / src / validation.js View on Github external
// Validation Chain
Validation[fl.chain] = Validation.chain;
Validation.prototype[fl.chain] = Validation.prototype.chain;

// Validation Functor
Validation[fl.map] = Validation.map;
Validation.prototype[fl.map] = Validation.prototype.map;

// Validation Apply
Validation[fl.ap] = Validation.ap;
Validation.prototype[fl.ap] = Validation.prototype.ap;

// Validation Semigroup
Validation[fl.concat] = Validation.concat;
Validation.prototype[fl.concat] = Validation.prototype.concat;

// Validation Monoid
Validation[fl.empty] = Validation.empty;
Validation.prototype[fl.empty] = Validation.prototype.empty;


// Success Applicative
Validation.Success[fl.of] = Validation.Success.of;
Validation.Success.prototype[fl.of] = Validation.Success.prototype.of;

// Failure Applicative
Validation.Failure[fl.of] = Validation.Failure.of;
Validation.Failure.prototype[fl.of] = Validation.Failure.prototype.of;


module.exports = Validation;
github char0n / ramda-adjunct / test / fantasy-land / Identity.js View on Github external
specify('should concatenate', function() {
        const arrayA = [1];
        const arrayB = [2];

        arrayA[fl.concat] = arrayA.concat;
        arrayB[fl.concat] = arrayB.concat;

        const a = RA.Identity.of(arrayA);
        const b = RA.Identity.of(arrayB);
        const c = a.concat(b);

        assert.sameOrderedMembers(c.get(), [1, 2]);
      });
    });
github sanctuary-js / sanctuary-type-classes / test / Maybe.js View on Github external
function _Maybe(tag, value) {
  this.isNothing = tag === 'Nothing';
  this.isJust = tag === 'Just';
  if (this.isJust) this.value = value;

  if (this.isNothing || Z.Setoid.test (this.value)) {
    this[FL.equals] = Maybe$prototype$equals;
  }

  if (this.isNothing || Z.Ord.test (this.value)) {
    this[FL.lte] = Maybe$prototype$lte;
  }

  if (this.isNothing || Z.Semigroup.test (this.value)) {
    this[FL.concat] = Maybe$prototype$concat;
  }
}
github fantasyland / static-land / src / fromFLType.js View on Github external
const concat = (ta, tb) => ta[$.concat](tb)
const ap = (tf, tx) => tx[$.ap](tf)
github fantasyland / static-land / src / fromFLType.js View on Github external
function defAvailableMethods(Constructor) {
  const result = []
  if (Constructor[$.of]) result.push('of')
  if (Constructor[$.empty]) result.push('empty')
  if (Constructor[$.chainRec]) result.push('chainRec')
  if (Constructor[$.zero]) result.push('zero')
  if (Constructor.prototype[$.equals]) result.push('equals')
  if (Constructor.prototype[$.map]) result.push('map')
  if (Constructor.prototype[$.bimap]) result.push('bimap')
  if (Constructor.prototype[$.promap]) result.push('promap')
  if (Constructor.prototype[$.concat]) result.push('concat')
  if (Constructor.prototype[$.ap]) result.push('ap')
  if (Constructor.prototype[$.alt]) result.push('alt')
  if (Constructor.prototype[$.reduce]) result.push('reduce')
  if (Constructor.prototype[$.traverse]) result.push('traverse')
  if (Constructor.prototype[$.chain]) result.push('chain')
  if (Constructor.prototype[$.extend]) result.push('extend')
  if (Constructor.prototype[$.extract]) result.push('extract')
  return result
}