<commit_before>//  Copyright (c) 2015 <NAME>. All rights reserved.

/// An enum representing either a failure with an explanatory error, or a success with a result value.
public enum Result<T>: EitherType {
	// MARK: Constructors

	/// Constructs a failure from an `error`.
	public static func failure(error: NSError) -> Result {
		return Failure(error)
	}

	/// Constructs a success from a `value`.
	public static func success(value: T) -> Result {
		return Success(Box(value))
	}


	// MARK: Properties

	/// Returns the error from `Failure` Results, `nil` otherwise.
	public var failure: NSError? {
		return either(id, const(nil))
	}

	/// Returns the value from `Success` Results, `nil` otherwise.
	public var success: T? {
		return either(const(nil), id)
	}


	// MARK: Cases

	case Failure(NSError)
	case Success(Box<T>)


	// MARK: EitherType

	public static func left(error: NSError) -> Result {
		return failure(error)
	}

	public static func right(value: T) -> Result {
		return success(value)
	}

	public func either<Result>(ifLeft: NSError -> Result, _ ifRight: T -> Result) -> Result {
		switch self {
		case let Failure(error):
			return ifLeft(error)

		case let Success(v):<commit_msg>Case analysis method.<commit_after>//  Copyright (c) 2015 <NAME>. All rights reserved.

/// An enum representing either a failure with an explanatory error, or a success with a result value.
public enum Result<T>: EitherType {
	// MARK: Constructors

	/// Constructs a failure from an `error`.
	public static func failure(error: NSError) -> Result {
		return Failure(error)
	}

	/// Constructs a success from a `value`.
	public static func success(value: T) -> Result {
		return Success(Box(value))
	}


	// MARK: Properties

	/// Returns the error from `Failure` Results, `nil` otherwise.
	public var failure: NSError? {
		return either(id, const(nil))
	}

	/// Returns the value from `Success` Results, `nil` otherwise.
	public var success: T? {
		return either(const(nil), id)
	}

	public func analysis<Result>(#ifFailure: NSError -> Result, ifSuccess: T -> Result) -> Result {
		switch self {
		case let Failure(error):
			return ifFailure(error)

		case let Success(value):
			return ifSuccess(value.value)
		}
	}


	// MARK: Cases

	case Failure(NSError)
	case Success(Box<T>)


	// MARK: EitherType

	public static func left(error: NSError) -> Result {
		return failure(error)
	}

	public static func right(value: T) -> Result {
		return success(value)
	}

	public func either<Result>(ifLeft: NSError -> Result, _ ifRight: T -> Result) -> Result {
		switch self {
		case let Failure(error):
			return ifLeft(error)

		case let Success(v):
{'fraction_non_alphanumeric': 0.12244897959183673, 'fraction_numerical': 0.0030234315948601664, 'mean_word_length': 3.5325342465753424, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 29, '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': '2086074', 'n_tokens_mistral': 902, 'n_tokens_neox': 801, 'n_words': 290}