ceylon / ceylon-js

DEPRECATED
Apache License 2.0
54 stars 9 forks source link

problem with curry & Sequentials redux #583

Closed jvasileff closed 9 years ago

jvasileff commented 9 years ago

This code is the same as https://github.com/ceylon/ceylon-js/issues/568, but with Sequential instead of List:

object seqUtils {
    shared [B*]([A*]) lift<A, B>(B(A) f)
        =>  shuffle(curry(map<A,B>))(f);

    shared [B*] map<A,B>([A*] list, B(A) f)
        =>  list.collect<B>(f); 

    shared [Integer*] double([Integer*] list)
        =>  uncurry(Sequential<Integer>.collect<Integer>)(list,2.times);
}

shared void breakIt2() {
    value double = seqUtils.lift(2.times);
    print(double([1,2,3]));          // [2] (bad, should be [2, 4, 6])
    print(seqUtils.double([1,2,3])); // [2, 4, 6] (good)
}
chochos commented 9 years ago

have you updated your language module and compiler? I just tested and got [2,4,6]

jvasileff commented 9 years ago

Ok @chochos, here's a super reduced version of what still fails:

shared void run() {
    Anything echoX(Anything _, Anything x)
        =>  x;

    Anything(Anything) id
        =   curry(echoX)(null);

    print(id([1,2,3])); // prints "1"
}