<commit_before>import {isMonad, isFunction, SpatialMonad} from "./monad";

module.exports = exports = Either;
exports.Right = Right;
exports.Left = Left;

function Either(fn) {
	try {
		return Right(fn());
	} catch(e) {
		return Left(e);
	}
}

function Right(value) {
	return isMonad(value) ? value : SpatialMonad(bindRight, value);
}

function Left(value) {
	return isMonad(value) ? value : SpatialMonad(bindLeft, value);
}

function bindRight(value, right) {
	return isFunction(right) ? Right(right(value)) : Right(value);
}

function bindLeft(value, right, left) {
	return isFunction(left) ? Right(left(value)) : Left(value);
}<commit_msg>use correct constructors<commit_after>import {isMonad, isFunction, SpatialMonad} from "./monad";

module.exports = exports = Either;
exports.Right = Right;
exports.Left = Left;

function Either(fn) {
	try {
		return Right(fn());
	} catch(e) {
		return Left(e);
	}
}

function Right(value) {
	return isMonad(value) ? value : SpatialMonad(Right, bindRight, value);
}

function Left(value) {
	return isMonad(value) ? value : SpatialMonad(Left, bindLeft, value);
}

function bindRight(value, right) {
	return isFunction(right) ? Right(right(value)) : Right(value);
}

function bindLeft(value, right, left) {
	return isFunction(left) ? Right(left(value)) : Left(value);
}
{'fraction_non_alphanumeric': 0.14984709480122324, 'fraction_numerical': 0.0, 'mean_word_length': 5.577889447236181, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2301759', 'n_tokens_mistral': 462, 'n_tokens_neox': 450, 'n_words': 104}