func ForEach(filter Filter, fn func(s string)) error {
	in := make(chan string)
	close(in)
	out := make(chan string, channelBuffer)
	e := &filterErrors{}
	go runFilter(filter, Arg{In: in, Out: out}, e)
	for s := range out {
		fn(s)
	}
	return e.getError()
}
ForEach calls fn(s) for every item s in the output of filter and
returns either nil, or any error reported by the execution of the filter.
package stream
import "sync"
type filterErrors struct {
	mu  sync.Mutex
	err error
}
func (e *filterErrors) record(err error) {
	if err != nil {
		e.mu.Lock()
		if e.err == nil {
			e.err = err
		}
		e.mu.Unlock()
	}
}
func (e *filterErrors) getError() error {
	e.mu.Lock()
	defer e.mu.Unlock()
	return e.err
}
type Arg struct {
	In    <-chan string
	Out   chan<- string
	dummy bool  
}
type Filter interface {
	RunFilter(Arg) error
}
type FilterFunc func(Arg) error
func (f FilterFunc) RunFilter(arg Arg) error { return f(arg) }
const channelBuffer = 1000
func Sequence(filters ...Filter) Filter {
	if len(filters) == 1 {
		return filters[0]
	}
	return FilterFunc(func(arg Arg) error {
		e := &filterErrors{}
		in := arg.In
		for _, f := range filters {
			c := make(chan string, channelBuffer)
			go runFilter(f, Arg{In: in, Out: c}, e)
			in = c
		}
		for s := range in {
			arg.Out <- s
		}
		return e.getError()
	})
}
func Run(filters ...Filter) error {
	return ForEach(Sequence(filters...), func(s string) {})
}