From 96e3e58d270b28907fe41f3179789bee13cb0cc7 Mon Sep 17 00:00:00 2001 From: David Chambers Date: Sat, 26 May 2018 18:52:21 +0200 Subject: [PATCH] sanctuary-either@1.0.x --- bower.json | 1 + index.js | 31 +++++++++---------------------- package.json | 1 + 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/bower.json b/bower.json index 3792456..bf1cbaf 100644 --- a/bower.json +++ b/bower.json @@ -21,6 +21,7 @@ "types" ], "dependencies": { + "sanctuary-either": "1.0.x", "sanctuary-show": "1.0.x", "sanctuary-type-classes": "9.0.x", "sanctuary-type-identifiers": "2.0.x" diff --git a/index.js b/index.js index 2c68285..25112a0 100644 --- a/index.js +++ b/index.js @@ -183,21 +183,24 @@ /* istanbul ignore else */ if (typeof module === 'object' && typeof module.exports === 'object') { - module.exports = f (require ('sanctuary-show'), + module.exports = f (require ('sanctuary-either'), + require ('sanctuary-show'), require ('sanctuary-type-classes'), require ('sanctuary-type-identifiers')); } else if (typeof define === 'function' && define.amd != null) { - define (['sanctuary-show', + define (['sanctuary-either', + 'sanctuary-show', 'sanctuary-type-classes', 'sanctuary-type-identifiers'], f); } else { - self.sanctuaryDef = f (self.sanctuaryShow, + self.sanctuaryDef = f (self.sanctuaryEither, + self.sanctuaryShow, self.sanctuaryTypeClasses, self.sanctuaryTypeIdentifiers); } -} (function(show, Z, type) { +} (function(Either, show, Z, type) { 'use strict'; @@ -207,27 +210,11 @@ var slice = Array.prototype.slice; var hasOwnProperty = Object.prototype.hasOwnProperty; - function Either(tag, value) { - this.isLeft = tag === 'Left'; - this.isRight = tag === 'Right'; - this.value = value; - } - - Either['@@type'] = 'sanctuary-def/Either'; - - Either.prototype['fantasy-land/map'] = function(f) { - return this.isLeft ? this : Right (f (this.value)); - }; - - Either.prototype['fantasy-land/chain'] = function(f) { - return this.isLeft ? this : f (this.value); - }; - // Left :: a -> Either a b - function Left(x) { return new Either ('Left', x); } + var Left = Either.Left; // Right :: b -> Either a b - function Right(x) { return new Either ('Right', x); } + var Right = Either.Right; // K :: a -> b -> a function K(x) { return function(y) { return x; }; } diff --git a/package.json b/package.json index ddb38cd..2075753 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "test": "npm run lint && sanctuary-test && npm run doctest" }, "dependencies": { + "sanctuary-either": "1.0.x", "sanctuary-show": "1.0.x", "sanctuary-type-classes": "9.0.x", "sanctuary-type-identifiers": "2.0.x"