Skip to content

Commit 8c0ee3a

Browse files
Merge pull request #206 from sanctuary-js/davidchambers/either
[email protected]
2 parents 6a25f61 + 96e3e58 commit 8c0ee3a

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

bower.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"types"
2222
],
2323
"dependencies": {
24+
"sanctuary-either": "1.0.x",
2425
"sanctuary-show": "1.0.x",
2526
"sanctuary-type-classes": "9.0.x",
2627
"sanctuary-type-identifiers": "2.0.x"

index.js

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -183,21 +183,24 @@
183183

184184
/* istanbul ignore else */
185185
if (typeof module === 'object' && typeof module.exports === 'object') {
186-
module.exports = f (require ('sanctuary-show'),
186+
module.exports = f (require ('sanctuary-either'),
187+
require ('sanctuary-show'),
187188
require ('sanctuary-type-classes'),
188189
require ('sanctuary-type-identifiers'));
189190
} else if (typeof define === 'function' && define.amd != null) {
190-
define (['sanctuary-show',
191+
define (['sanctuary-either',
192+
'sanctuary-show',
191193
'sanctuary-type-classes',
192194
'sanctuary-type-identifiers'],
193195
f);
194196
} else {
195-
self.sanctuaryDef = f (self.sanctuaryShow,
197+
self.sanctuaryDef = f (self.sanctuaryEither,
198+
self.sanctuaryShow,
196199
self.sanctuaryTypeClasses,
197200
self.sanctuaryTypeIdentifiers);
198201
}
199202

200-
} (function(show, Z, type) {
203+
} (function(Either, show, Z, type) {
201204

202205
'use strict';
203206

@@ -207,27 +210,11 @@
207210
var slice = Array.prototype.slice;
208211
var hasOwnProperty = Object.prototype.hasOwnProperty;
209212

210-
function Either(tag, value) {
211-
this.isLeft = tag === 'Left';
212-
this.isRight = tag === 'Right';
213-
this.value = value;
214-
}
215-
216-
Either['@@type'] = 'sanctuary-def/Either';
217-
218-
Either.prototype['fantasy-land/map'] = function(f) {
219-
return this.isLeft ? this : Right (f (this.value));
220-
};
221-
222-
Either.prototype['fantasy-land/chain'] = function(f) {
223-
return this.isLeft ? this : f (this.value);
224-
};
225-
226213
// Left :: a -> Either a b
227-
function Left(x) { return new Either ('Left', x); }
214+
var Left = Either.Left;
228215

229216
// Right :: b -> Either a b
230-
function Right(x) { return new Either ('Right', x); }
217+
var Right = Either.Right;
231218

232219
// K :: a -> b -> a
233220
function K(x) { return function(y) { return x; }; }

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"test": "npm run lint && sanctuary-test && npm run doctest"
1515
},
1616
"dependencies": {
17+
"sanctuary-either": "1.0.x",
1718
"sanctuary-show": "1.0.x",
1819
"sanctuary-type-classes": "9.0.x",
1920
"sanctuary-type-identifiers": "2.0.x"

0 commit comments

Comments
 (0)