Misleading Use of Currying in Type Signatures
Opened this issue · 7 comments
Jameshfisher of reddit made a good point:
http://www.reddit.com/r/javascript/comments/pholi/typedjs_sanity_check_your_code/c3pscxo
Bear in mind that the right-associative arrow does make sense where currying is actually going on. So Char -> Char -> Char
would be the appropriate signature for
//+ char_first :: Char -> Char -> Char
function char_first(c1){
return function(c2) {
return c1;
}
}
(I'm Jameshfisher :)
Right. But knowing whether a function can be curried (like your example) requires a bit of analysis that I'm not currently doing ;-) Maybe an extra feature later on.
I can't remember the Haskell equivalent exactly, but I think it would be //+ char_first :: Char Char -> Char
. Another option, if the delimiter is necessary, might be //+ char_first :: Char * Char -> Char
, a la ML.
//+ add :: Number, Number -> Number
currently works.
Nice!
Love the principle of TypedJS but having some problems using it so, with apologies if I'm being a "DA"....
Does currying work? I tried a simple function:
fnCurry = function (a) { return function (b) { return true; } };
and then used
test = TypedJS.addTest("fnCurry :: Number -> Number -> Boolean", fnCurry);
TypedJS.go([test]);
but it fails 300 times with
Expected "boolean" but returned undefined on input: [62,33]
No, currying doesn't work :(