<commit_before>//
//  RACStream.h
//  ReactiveCocoa
//
//  Created by <NAME> on 2012-10-31.
//  Copyright (c) 2012 GitHub, Inc. All rights reserved.
//

#import <Foundation/Foundation.h>

@class RACStream;

// A block which accepts a value from a RACStream and returns a new instance
// of the same stream class.
//
// Setting `stop` to `YES` will cause the bind to terminate after the returned
// value. Returning `nil` will result in immediate termination.
typedef RACStream * (^RACStreamBindBlock)(id value, BOOL *stop);

// An abstract class representing any stream of values.
//
// This class represents a monad, upon which many stream-based operations can
// be built.
//
// When subclassing RACStream, only the methods in the main @interface body need
// to be overridden.
@interface RACStream : NSObject

// Returns an empty stream.
+ (instancetype)empty;

// Lifts `value` into the stream monad.
//
// Returns a stream containing only the given value.
+ (instancetype)return:(id)value;

// Lazily binds a block to the values in the receiver.
//
// This should only be used if you need to terminate the bind early, or close
// over some state. -flattenMap: is more appropriate for all other cases.
//
// block - A block returning a RACStreamBindBlock. This block will be invoked
//         each time the bound stream is re-evaluated. This block must not be
//         nil or return nil.
//
// Returns a new stream which represents the combined result of all lazy
// applications of `block`.
- (instancetype)bind:(RACStreamBindBlock (^)(void))block;

// Appends the values of `stream` to the values in the receiver.
//
// stream - A stream to concatenate. This must be an instance of the same
//          concrete class as the receiver, and should not be `nil`.
//
// Returns a new stream representing the receiver followed by `stream`.
- (instancetype)concat:(RACStream *)stream;

// Zips the values in the receiver with those of the given stream to create
// RACTuples.
//
// The first value of each stream will be combined, then the second value, and
// so forth, until at least one of the streams is exhausted.
//
// stream - The stream to zip with. This must be an instance of the same
//          concrete class as the receiver, and should not be `nil`.
//
// Returns a new stream of RACTuples, representing the zipped values of the
// two streams.
- (instancetype)zipWith:(RACStream *)stream;

@end

// This extension contains functionality to support naming streams for
// debugging.
//
// Subclasses do not need to override the methods here.
@interface RACStream ()

// The name of the stream. This is for debugging/human purposes only.
@property (copy) NSString *name;

// Sets the name of the receiver to the given format string.
//
// This is for debugging purposes only, and won't do anything unless the DEBUG
// preprocessor macro is defined.
//
// Returns the receiver, for easy method chaining.
- (instancetype)setNameWithFormat:(NSString *)format, ... NS_FORMAT_FUNCTION(1, 2);

@end

// Operations built on the RACStream primitives.
//
// These methods do not need to be overridden, although subclasses may
// occasionally gain better performance from doing so.
@interface RACStream (Operations)

// Maps `block` across the values in the receiver and flattens the result.
//
// This corresponds to the `SelectMany` method in Rx.
//
// block - A block which accepts the values in the receiver and returns a new
//         instance of the receiver's class. This block should not return `nil`.
//
// Returns a new stream which represents the combined streams resulting from
// mapping `block`.
- (instancetype)flattenMap:(RACStream * (^)(id value))block;

// Flattens a stream of streams.
//
// This corresponds to the `Merge` method in Rx.
//
// Returns a stream consisting of the combined streams obtained from the
// receiver.
- (instancetype)flatten;

// Maps `block` across the values in the receiver.
//
// This corresponds to the `Select` method in Rx.
//
// Returns a new stream with the mapped values.
- (instancetype)map:(id (^)(id value))block;<commit_msg>-flattenMap: examples with operators applied after/within<commit_after>//
//  RACStream.h
//  ReactiveCocoa
//
//  Created by <NAME> on 2012-10-31.
//  Copyright (c) 2012 GitHub, Inc. All rights reserved.
//

#import <Foundation/Foundation.h>

@class RACStream;

// A block which accepts a value from a RACStream and returns a new instance
// of the same stream class.
//
// Setting `stop` to `YES` will cause the bind to terminate after the returned
// value. Returning `nil` will result in immediate termination.
typedef RACStream * (^RACStreamBindBlock)(id value, BOOL *stop);

// An abstract class representing any stream of values.
//
// This class represents a monad, upon which many stream-based operations can
// be built.
//
// When subclassing RACStream, only the methods in the main @interface body need
// to be overridden.
@interface RACStream : NSObject

// Returns an empty stream.
+ (instancetype)empty;

// Lifts `value` into the stream monad.
//
// Returns a stream containing only the given value.
+ (instancetype)return:(id)value;

// Lazily binds a block to the values in the receiver.
//
// This should only be used if you need to terminate the bind early, or close
// over some state. -flattenMap: is more appropriate for all other cases.
//
// block - A block returning a RACStreamBindBlock. This block will be invoked
//         each time the bound stream is re-evaluated. This block must not be
//         nil or return nil.
//
// Returns a new stream which represents the combined result of all lazy
// applications of `block`.
- (instancetype)bind:(RACStreamBindBlock (^)(void))block;

// Appends the values of `stream` to the values in the receiver.
//
// stream - A stream to concatenate. This must be an instance of the same
//          concrete class as the receiver, and should not be `nil`.
//
// Returns a new stream representing the receiver followed by `stream`.
- (instancetype)concat:(RACStream *)stream;

// Zips the values in the receiver with those of the given stream to create
// RACTuples.
//
// The first value of each stream will be combined, then the second value, and
// so forth, until at least one of the streams is exhausted.
//
// stream - The stream to zip with. This must be an instance of the same
//          concrete class as the receiver, and should not be `nil`.
//
// Returns a new stream of RACTuples, representing the zipped values of the
// two streams.
- (instancetype)zipWith:(RACStream *)stream;

@end

// This extension contains functionality to support naming streams for
// debugging.
//
// Subclasses do not need to override the methods here.
@interface RACStream ()

// The name of the stream. This is for debugging/human purposes only.
@property (copy) NSString *name;

// Sets the name of the receiver to the given format string.
//
// This is for debugging purposes only, and won't do anything unless the DEBUG
// preprocessor macro is defined.
//
// Returns the receiver, for easy method chaining.
- (instancetype)setNameWithFormat:(NSString *)format, ... NS_FORMAT_FUNCTION(1, 2);

@end

// Operations built on the RACStream primitives.
//
// These methods do not need to be overridden, although subclasses may
// occasionally gain better performance from doing so.
@interface RACStream (Operations)

// Maps `block` across the values in the receiver and flattens the result.
//
// Note that operators applied _after_ -flattenMap: behave differently from
// operators _within_ -flattenMap:. See the Examples section below.
//
// This corresponds to the `SelectMany` method in Rx.
//
// block - A block which accepts the values in the receiver and returns a new
//         instance of the receiver's class. This block should not return `nil`.
//
// Examples
//
//   [signal flattenMap:^(id x) {
//       // Logs each time a returned signal completes.
//       return [[RACSignal return:x] logCompleted];
//   }];
//
//   [[signal
//       flattenMap:^(id x) {
//           return [RACSignal return:x];
//       }]
//       // Logs only once, when all of the signals complete.
//       logCompleted];
//
// Returns a new stream which represents the combined streams resulting from
// mapping `block`.
- (instancetype)flattenMap:(RACStream * (^)(id value))block;

// Flattens a stream of streams.
//
// This corresponds to the `Merge` method in Rx.
//
// Returns a stream consisting of the combined streams obtained from the
// receiver.
- (instancetype)flatten;

// Maps `block` across the values in the receiver.
//
// This corresponds to the `Select` method in Rx.
//
// Returns a new stream with the mapped values.
- (instancetype)map:(id (^)(id value))block;
{'fraction_non_alphanumeric': 0.10107724043089618, 'fraction_numerical': 0.0032088012835205133, 'mean_word_length': 3.173601147776184, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5209603', 'n_tokens_mistral': 2478, 'n_tokens_neox': 2364, 'n_words': 1150}