<commit_before>package org.rocket.network.netty;

import io.netty.channel.ChannelFuture;
import org.fungsi.Unit;
import org.fungsi.concurrent.Future;
import org.fungsi.concurrent.Promise;
import org.fungsi.concurrent.Promises;

public final class ChannelFutures {
    private ChannelFutures() {}

    public static Future<Unit> toFungsi(ChannelFuture fut) {
        Promise<Unit> p = Promises.create();
        fut.addListener(it -> p.set(Unit.left()));
        return p;
    }
}<commit_msg>handles failures too<commit_after>package org.rocket.network.netty;

import io.netty.channel.ChannelFuture;
import org.fungsi.Either;
import org.fungsi.Unit;
import org.fungsi.concurrent.Future;
import org.fungsi.concurrent.Promise;
import org.fungsi.concurrent.Promises;

public final class ChannelFutures {
    private ChannelFutures() {}

    public static Future<Unit> toFungsi(ChannelFuture fut) {
        Promise<Unit> p = Promises.create();

        fut.addListener(f -> {
            if (f.isSuccess()) {
                p.set(Unit.left());
            } else {
                p.set(Either.failure(f.cause()));
            }
        });

        return p;
    }
}
{'fraction_non_alphanumeric': 0.12123817712811694, 'fraction_numerical': 0.0, 'mean_word_length': 2.9726962457337884, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '7660360', 'n_tokens_mistral': 373, 'n_tokens_neox': 364, 'n_words': 68}