<commit_before>/*
Package channels provides a collection of helper functions, interfaces and special types for
working with and extending the capabilities of golang's existing channels.

Several types in this package provide so-called "infinite" buffers. Be *very* careful using these, as no
buffer is truly infinite - if such a buffer grows too large your program will run out of memory and crash.
Caveat emptor.
*/
package channels

// BufferCap represents the capacity of the buffer backing a channel. Valid values consist of all
// positive integers, as well as the special values below.
type BufferCap int

const (
	None     BufferCap = 0
	Infinity BufferCap = -1
)

// InChannel is an interface representing a writeable channel.
type InChannel interface {
	In() chan<- interface{} // The writeable end of the channel.
	Len() int               // The number of elements currently buffered.
	Cap() BufferCap         // The size of the backing buffer.
	Close()                 // Closes the channel.
}

// OutChannel is an interface representing a readable channel.
type OutChannel interface {
	Out() <-chan interface{} // The readable end of the channel.
	Len() int                // The number of elements currently buffered.
	Cap() BufferCap          // The size of the backing buffer.
}

// Channel is an interface representing a channel that is both readable and writeable.
type Channel interface {
	In() chan<- interface{}  // The writeable end of the channel.
	Out() <-chan interface{} // The readable end of the channel.
	Len() int                // The number of elements currently buffered.
	Cap() BufferCap          // The size of the backing buffer.
	Close()                  // Closes the channel.
}

// Pipe connects the input channel to the output channel so that
// they behave as if a single channel.
func Pipe(input OutChannel, output InChannel) {
	go func() {
		for elem := range input.Out() {
			output.In() <- elem
		}
		output.Close()
	}()
}<commit_msg>Rework interface hierarchy<commit_after>/*
Package channels provides a collection of helper functions, interfaces and special types for
working with and extending the capabilities of golang's existing channels.

Several types in this package provide so-called "infinite" buffers. Be *very* careful using these, as no
buffer is truly infinite - if such a buffer grows too large your program will run out of memory and crash.
Caveat emptor.
*/
package channels

// BufferCap represents the capacity of the buffer backing a channel. Valid values consist of all
// positive integers, as well as the special values below.
type BufferCap int

const (
	None     BufferCap = 0
	Infinity BufferCap = -1
)

// Buffer is an interface for any channel that provides access to query the state of its buffer.
// Even unbuffered channels can implement this interface by simply returning 0 from Len() and None from Cap().
type Buffer interface {
	Len() int       // The number of elements currently buffered.
	Cap() BufferCap // The maximum number of elements that can be buffered.
}

// SimpleInChannel is an interface representing a writeable channel that does not necessarily
// implement the Buffer interface.
type SimpleInChannel interface {
	In() chan<- interface{} // The writeable end of the channel.
	Close()                 // Closes the channel. It is an error to write to In() after calling Close().
}

// InChannel is an interface representing a writeable channel with a buffer.
type InChannel interface {
	SimpleInChannel
	Buffer
}

// SimpleOutChannel is an interface representing a readable channel that does not necessarily
// implement the Buffer interface.
type SimpleOutChannel interface {
	Out() <-chan interface{} // The readable end of the channel.
}

// OutChannel is an interface representing a readable channel implementing the Buffer interface.
type OutChannel interface {
	SimpleOutChannel
	Buffer
}

// SimpleChannel is an interface representing a channel that is both readable and writeable,
// but does not necessarily implement the Buffer interface.
type SimpleChannel interface {
	SimpleInChannel
	SimpleOutChannel
}

// Channel is an interface representing a channel that is readable, writeable and implements
// the Buffer interface
type Channel interface {
	SimpleChannel
	Buffer
}

// Pipe connects the input channel to the output channel so that
// they behave as if a single channel.
func Pipe(input SimpleOutChannel, output SimpleInChannel) {
	go func() {
		for elem := range input.Out() {
			output.In() <- elem
		}
		output.Close()
	}()
}
{'fraction_non_alphanumeric': 0.0673860383175512, 'fraction_numerical': 0.001101079057476327, 'mean_word_length': 3.3884057971014494, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1005808', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1084, 'n_words': 599}