All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aol.cyclops.functionaljava.comprehenders.TrampolineComprehender Maven / Gradle / Ivy

There is a newer version: 9.0.0-MI7
Show newest version
package com.aol.cyclops.functionaljava.comprehenders;

import java.util.function.Function;

import com.aol.cyclops.types.extensability.Comprehender;
import com.aol.cyclops.types.extensability.ValueComprehender;

import fj.control.Trampoline;
import fj.data.Option;

public class TrampolineComprehender implements ValueComprehender {

    @Override
    public Object resolveForCrossTypeFlatMap(Comprehender comp, Trampoline apply) {
        return comp.of(apply.run());
    }

    @Override
    public Object map(Trampoline t, Function fn) {
        return t.map(r -> fn.apply(r));
    }

    @Override
    public Object flatMap(Trampoline t, Function fn) {
        return t.bind(r -> fn.apply(r));
    }

    @Override
    public Trampoline of(Object o) {
        return Trampoline.pure(o);
    }

    @Override
    public Trampoline empty() {
        return Trampoline.pure(Option.none());
    }

    @Override
    public Class getTargetClass() {
        return Trampoline.class;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy