<commit_before>package me.elrod.pureio;

import java.util.function.BiFunction;
import java.util.function.Function;

/**
 * An optional type.
 */
public abstract class Maybe<T> {
    private Maybe() {}

    /**
     * Catamorphism over Maybe<A>.
     */
    public abstract <U> U cata(
        Function<T, U> some,
        U none);

    // Functor
    public <U> Maybe<U> fmap(final Function<T, U> fn) {
        return this.cata(
            new Function<T, Maybe<U>>() {
                public Maybe<U> apply(T x) {
                    return point(fn.apply(x));
                }
            },
            new None<U>());
    }

    // Applicative
    public <U> Maybe<U> applyVia(final Maybe<Function<T,U>> ofn) {
        return ofn.cata(
            new Function<Function<T, U>, Maybe<U>>() {
                public Maybe<U> apply(final Function<T, U> fn) {
                    return Maybe.this.fmap(fn);<commit_msg>same with fmap -> map<commit_after>package me.elrod.pureio;

import java.util.function.BiFunction;
import java.util.function.Function;

/**
 * An optional type.
 */
public abstract class Maybe<T> {
    private Maybe() {}

    /**
     * Catamorphism over Maybe<A>.
     */
    public abstract <U> U cata(
        Function<T, U> some,
        U none);

    // Functor
    public <U> Maybe<U> map(final Function<T, U> fn) {
        return this.cata(
            new Function<T, Maybe<U>>() {
                public Maybe<U> apply(T x) {
                    return point(fn.apply(x));
                }
            },
            new None<U>());
    }

    // Applicative
    public <U> Maybe<U> applyVia(final Maybe<Function<T,U>> ofn) {
        return ofn.cata(
            new Function<Function<T, U>, Maybe<U>>() {
                public Maybe<U> apply(final Function<T, U> fn) {
                    return Maybe.this.map(fn);
{'fraction_non_alphanumeric': 0.1406926406926407, 'fraction_numerical': 0.0, 'mean_word_length': 1.7930513595166162, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 44, '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': '1883897', 'n_tokens_mistral': 600, 'n_tokens_neox': 577, 'n_words': 142}