Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>Yes and no. Curried-by-default is the source of a lot of Haskell's power, and that requires a certain amount of unusual ordering. The terseness of pointfree style is worth some learning time.

Correct me if I'm wrong, but you don't need Haskell's syntax to have automatically curried functions or a pointfree style. Using a JS-like syntax as an example:

    function add(a, b) {
        return a + b;
    }
    // functions could be automatically curried,
    // so you could do this:
    let add5 = add(5);
    
    add5(10) // => 15
    

    // "Normal" sum definition
    function sum(list) {
        return reduce(add, 0, list); 
    }

    // Pointfree version
    function sum() {
       // returns a function that takes
       // 1 argument (the list)
       return reduce(add, 0);
    }


You can do that up to a point, but you pay a cost for it. It means functions are taking up a big chunk of your available syntax space, and it can make things ambiguous if something might be seen as both a function and a value. Look at how it works in Scala: much of the time you can call a function partially, but in an unsatisfyingly random-feeling set of cases you need to explicitly use "_" expansion.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: