These are chat archives for ramda/ramda

8th
Jul 2015
Hardy Jones
@joneshf
Jul 08 2015 10:17
How does ramda build documentation?
Kevin Wallace
@kedashoe
Jul 08 2015 15:22
James Forbes
@JAForbes
Jul 08 2015 23:36

Hey guys, you had any thoughts on currying functions with named arguments? It kind of solves the order of arguments problem. Do any languages support it?

And given ES6 sort of supports named arguments (http://www.2ality.com/2011/11/keyword-parameters.html) perhaps it is possible to do it in JS?

James Forbes
@JAForbes
Jul 08 2015 23:44
//maybe undefined can signify a non optional argument?
fundtion request( { protocol = "https", url = undefined, port = "80" } ){
   return protocal + "://" + url + ":" + port == 80 ? "" : port;
}

request() //=> request()

request( { url: "google.com" } ) //=>  "https://google.com"

customPort = request({ port: 3000 , protocol: "http" }) 

customPort( {url = "localhost" } ) //=> "http://localhost:3000"
David Chambers
@davidchambers
Jul 08 2015 23:45
In one sense currying itself solves the order of arguments problem.
One can very often predict the order of arguments by thinking about the usefulness of the partially applied form(s).
For example, R.is(Number) is clearly useful in many contexts, whereas R.is(obj) is not. Therefore, I predict that R.is has type Type -> a -> Boolean rather than a -> Type -> Boolean.