<commit_before>
#pragma once

#include "pipe.hpp"

namespace lambda {
namespace streams {

//
// `Stream` concept
//
struct Stream {
    using Type = void;
    Maybe<Type> next();
};

template <class C>
class CollectionStream : public Stream {
    C collection;
    typename C::const_iterator begin, end;

public:
    using Type = typename C::value_type;

    explicit CollectionStream(C &&collection)
        : collection(collection), begin(collection.cbegin()), end(collection.cend()) {}

    Maybe<Type> next() { return begin != end ? some(std::move(*begin++)) : none; }
};

template <class C, REQUIRE_CONCEPT(has_iterator_v<C>)>
auto stream(C &&c) {
    return CollectionStream<C>{std::forward<C>(c)};
}

template <class F>
class FunctionStream : public Stream {
    F f;

public:
    using Type = typename std::result_of_t<decltype(std::declval<F>)>::value_type; // Maybe::Type

    explicit FunctionStream(F &&f) : f(f) {}

    Maybe<Type> next() { return f(); }
};

template <class F, class = std::enable_if_t<is_callable_v<F>>>
auto stream(F &&f) {
    return FunctionStream<F>{std::forward<F>(f)};
}

} /* streams */
} /* lambda */<commit_msg>Update.<commit_after>
#pragma once

#include "pipe.hpp"

namespace lambda {
namespace streams {

//
// `Stream` concept
//
struct Stream {
    using Type = void;
    Maybe<Type> next();
};

template <class C>
class CollectionStream : public Stream {
    C collection;
    typename C::const_iterator begin, end;

public:
    using Type = typename C::value_type;

    explicit CollectionStream(C &&collection)
        : collection(collection), begin(collection.cbegin()), end(collection.cend()) {}

    Maybe<Type> next() { return begin != end ? some(std::move(*begin++)) : none; }
};

template <class C, REQUIRE_CONCEPT(has_iterator_v<C>)>
auto stream(C &&c) {
    return CollectionStream<C>{std::forward<C>(c)};
}

template <class F>
class FunctionStream : public Stream {
    F f;

public:
    using Type = typename decltype(f())::value_type; // Maybe::Type

    explicit FunctionStream(F &&f) : f(f) {}

    Maybe<Type> next() { return f(); }
};

template <class F, class = std::enable_if_t<is_callable_v<F>>>
auto stream(F &&f) {
    return FunctionStream<F>{std::forward<F>(f)};
}

} /* streams */
} /* lambda */
{'fraction_non_alphanumeric': 0.16534391534391535, 'fraction_numerical': 0.0, 'mean_word_length': 4.133484162895928, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, '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': '7530052', 'n_tokens_mistral': 754, 'n_tokens_neox': 741, 'n_words': 186}