(function(){
var Result, ref$, Left, Right, handleError, devResult, handleException, out$ = typeof exports != 'undefined' && exports || this;
Result = require('./result');
ref$ = require('fantasy-eithers'), Left = ref$.Left, Right = ref$.Right;
out$.handleError = handleError = curry$(function(f, g, e){
return e.fold(f, g);
});
out$.devResult = devResult = handleError(function(err){
return Result.error(e.stack).extract();
}, function(res){
return Result.ok(res).extract();
});
out$.handleException = handleException = function(f){
return function(){
var e;
try {
return Right(f.apply(this, arguments));
} catch (e$) {
e = e$;
return Left(e);
}
};
};
function curry$(f, bound){
var context,
_curry = function(args) {
return f.length > 1 ? function(){
var params = args ? args.concat() : [];
context = bound ? context || this : this;
return params.push.apply(params, arguments) <
f.length && arguments.length ?
_curry.call(context, params) : f.apply(context, params);
} : f;
};
return _curry();
}
}).call(this);
|