<commit_before>// Shirley
// Written in 2015 by <NAME> <<EMAIL>>
//
// To the extent possible under law, the author(s) have dedicated all copyright and
// related and neighboring rights to this software to the public domain worldwide.
// This software is distributed without any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication along with
// this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

import Foundation
import ReactiveCocoa

/// Applies a transform to a session's values or errors, creating a new session. This type is wrapped in `Session`
/// before being returned publically.
internal struct TransformSession<Request, Value, Error: ErrorType>
{
    // MARK: - Initialization
    
    /**
    Initializes a value transform session.
    
    - parameter session:         The session to wrap.
    - parameter flattenStrategy: The flatten strategy to use when transforming.
    - parameter transform:       The transform function.
    */
    init<Wrapped: SessionType where Request == Wrapped.Request, Error == Wrapped.Error>
        (session: Wrapped, flattenStrategy: FlattenStrategy, transform: Wrapped.Value -> SignalProducer<Value, Error>)
    {
        producerFunction = { request in
            session.producerForRequest(request).flatMap(flattenStrategy, transform: transform)
        }
    }
    
    /**
    Initializes a error transform session.
    
    - parameter session:        The session to wrap.
    - parameter transformError: The transform function.
    */
    init<Wrapped: SessionType where Request == Wrapped.Request, Value == Wrapped.Value>
        (session: Wrapped, transformError: Wrapped.Error -> SignalProducer<Value, Error>)
    {
        producerFunction = { request in
            session.producerForRequest(request).flatMapError(transformError)
        }
    }
    
    // MARK: - Properties
    
    /// Wraps the inner session without directly referencing its type.
    let producerFunction: Request -> SignalProducer<Value, Error>
}

extension TransformSession: SessionType<commit_msg>What is grammar?<commit_after>// Shirley
// Written in 2015 by <NAME> <<EMAIL>>
//
// To the extent possible under law, the author(s) have dedicated all copyright and
// related and neighboring rights to this software to the public domain worldwide.
// This software is distributed without any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication along with
// this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

import Foundation
import ReactiveCocoa

/// Applies a transform to a session's values or errors, creating a new session. This type is wrapped in `Session`
/// before being returned publically.
internal struct TransformSession<Request, Value, Error: ErrorType>
{
    // MARK: - Initialization
    
    /**
    Initializes a value transform session.
    
    - parameter session:         The session to wrap.
    - parameter flattenStrategy: The flatten strategy to use when transforming.
    - parameter transform:       The transform function.
    */
    init<Wrapped: SessionType where Request == Wrapped.Request, Error == Wrapped.Error>
        (session: Wrapped, flattenStrategy: FlattenStrategy, transform: Wrapped.Value -> SignalProducer<Value, Error>)
    {
        producerFunction = { request in
            session.producerForRequest(request).flatMap(flattenStrategy, transform: transform)
        }
    }
    
    /**
    Initializes an error transform session.
    
    - parameter session:        The session to wrap.
    - parameter transformError: The transform function.
    */
    init<Wrapped: SessionType where Request == Wrapped.Request, Value == Wrapped.Value>
        (session: Wrapped, transformError: Wrapped.Error -> SignalProducer<Value, Error>)
    {
        producerFunction = { request in
            session.producerForRequest(request).flatMapError(transformError)
        }
    }
    
    // MARK: - Properties
    
    /// Wraps the inner session without directly referencing its type.
    let producerFunction: Request -> SignalProducer<Value, Error>
}

extension TransformSession: SessionType
{'fraction_non_alphanumeric': 0.08563931297709923, 'fraction_numerical': 0.0033396946564885495, 'mean_word_length': 3.0047755491881567, 'pattern_counts': {'":': 0, '<': 23, '<?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': '6620648', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1043, 'n_words': 387}