com.aol.cyclops.functionaljava.comprehenders.IOComprehender Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cyclops-functionaljava Show documentation
Show all versions of cyclops-functionaljava Show documentation
Converters and Comprehenders for FunctionalJava
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.data.IO;
import fj.data.IOFunctions;
import fj.data.Option;
public class IOComprehender implements ValueComprehender {
@Override
public Object resolveForCrossTypeFlatMap(Comprehender comp, IO apply) {
return comp.empty();
}
@Override
public Object map(IO t, Function fn) {
return IOFunctions.map(t, r -> fn.apply(r));
}
@Override
public Object flatMap(IO t, Function fn) {
return IOFunctions.flatMap(t, r -> (IO) fn.apply(r));
}
@Override
public IO of(Object o) {
return IOFunctions.unit(o);
}
@Override
public IO empty() {
return IOFunctions.unit(Option.none());
}
@Override
public Class getTargetClass() {
return IO.class;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy