如果我有F<A, B>,如何将现有的Ord<A>转换为Ord<B>
例如:
public class Foo {
public String name;
}
F<Foo, String> f = new F<Foo, String>() {
public String f(Foo foo) {
return foo.name;
}
};
Ord<String> stringOrd = Ord.stringOrd;
Ord<Foo> fooOrd = ???发布于 2015-01-20 04:03:01
答案是在API中的抓取。comap
Ord<Foo> fooOrd = Ord.stringOrd.comap(new F<Foo, String>() {
public String f(Foo foo) {
return foo.name;
}
});https://stackoverflow.com/questions/28037568
复制相似问题