-
Notifications
You must be signed in to change notification settings - Fork 56
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
[feature request] currying support #299
Comments
Currently, MoonBit does not support currying. We originally wanted to implement the pipe syntax similar to the Hack style pipe, where
The reason it is For example, given |
I prefer
|
maybe |
I noticed an expample of pipe in the doc
Looks like moonbit has currying and if I have a functiong
fn f(x:Int, y:Int)->Int
, thenlet g = f(2)
makesg
a function that takes one Int and output a Int, andg(3)
is equal tof(3,2)
. But moon reports an error on it "This function has type (Int, Int) -> Int, which requires 2 arguments, but is given 1 arguments."I think adding currying to moon makes
x |> f(y)
syntax more reasonable.By the way, it is a bit strange that
x |> f(y)
is equivalent tof(x,y)
notf(y,x)
.In my opinion, it is OK to make it a feature that parameters are pushed from right to left (so that in
f(y)
takes y as the second parameter), but then type of a functionfn (x:Int, y:Float)->Float
maybe better to have type(Float, Int)->Float
ofFloat -> Int -> Float
instead of(Int, Float)->Float
.The text was updated successfully, but these errors were encountered: