Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading Use of Currying in Type Signatures #12

Open
Ejhfast opened this issue Feb 11, 2012 · 7 comments
Open

Misleading Use of Currying in Type Signatures #12

Ejhfast opened this issue Feb 11, 2012 · 7 comments

Comments

@Ejhfast
Copy link
Owner

Ejhfast commented Feb 11, 2012

Jameshfisher of reddit made a good point:

http://www.reddit.com/r/javascript/comments/pholi/typedjs_sanity_check_your_code/c3pscxo

@jameshfisher
Copy link

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 :)

@Ejhfast
Copy link
Owner Author

Ejhfast commented Feb 11, 2012

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.

@panesofglass
Copy link

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.

@goatslacker
Copy link
Contributor

//+ add :: Number, Number -> Number currently works.

@panesofglass
Copy link

Nice!

@DazWilkin
Copy link
Contributor

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]

@goatslacker
Copy link
Contributor

No, currying doesn't work :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants