<commit_before>//
//  Event.swift
//  ReactiveCocoa
//
//  Created by <NAME> on 2015-01-16.
//  Copyright (c) 2015 GitHub. All rights reserved.
//

/// Represents a signal event.
///
/// Signals must conform to the grammar:
/// `Next* (Failed | Completed | Interrupted)?`
public enum Event<Value, Error: ErrorType> {
	/// A value provided by the signal.
	case Next(Value)

	/// The signal terminated because of an error. No further events will be
	/// received.
	case Failed(Error)

	/// The signal successfully terminated. No further events will be received.
	case Completed

	/// Event production on the signal has been interrupted. No further events
	/// will be received.
	///
	/// - important: This event does not signify the successful or failed
	///	             completion of the signal.
	case Interrupted

	/// Whether this event indicates signal termination (i.e., that no further
	/// events will be received).
	public var isTerminating: Bool {
		switch self {
		case .Next:
			return false

		case .Failed, .Completed, .Interrupted:
			return true
		}
	}

	/// Lifts the given closure over the event's value.
	///
	/// - parameters:
	///   - f: A closure that acceps a value and returning event with a
	///	       different type of value.
	///
	/// - important: The closure is called only on `Next` type events.
	public func map<U>(f: Value -> U) -> Event<U, Error> {
		switch self {
		case let .Next(value):
			return .Next(f(value))

		case let .Failed(error):
			return .Failed(error)

		case .Completed:
			return .Completed

		case .Interrupted:
			return .Interrupted
		}
	}

	/// Lifts the given closure over the event's error.
	///
	/// - parameters:
	///   - f: A closure that accepts an error object and returning
	///	       different type of error object.
	///
	/// - important: The closure is called only on `Failed` type event.
	public func mapError<F>(f: Error -> F) -> Event<Value, F> {
		switch self {
		case let .Next(value):
			return .Next(value)

		case let .Failed(error):
			return .Failed(f(error))

		case .Completed:
			return .Completed

		case .Interrupted:
			return .Interrupted
		}
	}

	/// Unwraps the contained `Next` value.
	public var value: Value? {
		if case let .Next(value) = self {
			return value
		} else {
			return nil
		}
	}

	/// Unwraps the contained `Error` value.
	public var error: Error? {
		if case let .Failed(error) = self {
			return error<commit_msg>Proofreading for `Event.swift`<commit_after>//
//  Event.swift
//  ReactiveCocoa
//
//  Created by <NAME> on 2015-01-16.
//  Copyright (c) 2015 GitHub. All rights reserved.
//

/// Represents a signal event.
///
/// Signals must conform to the grammar:
/// `Next* (Failed | Completed | Interrupted)?`
public enum Event<Value, Error: ErrorType> {
	/// A value provided by the signal.
	case Next(Value)

	/// The signal terminated because of an error. No further events will be
	/// received.
	case Failed(Error)

	/// The signal successfully terminated. No further events will be received.
	case Completed

	/// Event production on the signal has been interrupted. No further events
	/// will be received.
	///
	/// - important: This event does not signify the successful or failed
	///	             completion of the signal.
	case Interrupted

	/// Whether this event indicates signal termination (i.e., that no further
	/// events will be received).
	public var isTerminating: Bool {
		switch self {
		case .Next:
			return false

		case .Failed, .Completed, .Interrupted:
			return true
		}
	}

	/// Lifts the given closure over the event's value.
	///
	/// - parameters:
	///   - f: A closure that accepts a value and returns
	///        a new value
	///
	/// - important: The closure is called only on `Next` type events.
	public func map<U>(f: Value -> U) -> Event<U, Error> {
		switch self {
		case let .Next(value):
			return .Next(f(value))

		case let .Failed(error):
			return .Failed(error)

		case .Completed:
			return .Completed

		case .Interrupted:
			return .Interrupted
		}
	}

	/// Lifts the given closure over the event's error.
	///
	/// - parameters:
	///   - f: A closure that accepts an error object and returns
	///        a new error object
	///
	/// - important: The closure is called only on `Failed` type event.
	public func mapError<F>(f: Error -> F) -> Event<Value, F> {
		switch self {
		case let .Next(value):
			return .Next(value)

		case let .Failed(error):
			return .Failed(f(error))

		case .Completed:
			return .Completed

		case .Interrupted:
			return .Interrupted
		}
	}

	/// Unwraps the contained `Next` value.
	public var value: Value? {
		if case let .Next(value) = self {
			return value
		} else {
			return nil
		}
	}

	/// Unwraps the contained `Error` value.
	public var error: Error? {
		if case let .Failed(error) = self {
			return error
{'fraction_non_alphanumeric': 0.12242776969445021, 'fraction_numerical': 0.004988567865308668, 'mean_word_length': 2.4693583273251623, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, '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': '3493586', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1458, 'n_words': 570}