4 ms·
Why isn't it let foo : & (&[MyType] -> i32) -> String = ... Like in Haskell? Seems having both `fn` and `->` is unnecessary?
by thomasahle 4y ago
Why isn't it
let foo : & (&[MyType] -> i32) -> String = ...
Like in Haskell? Seems having both `fn` and `->` is unnecessary?
- nicoburns 4y agoWell the syntax for declaring a function in Rust is: fn foo_bar(foo: &[MyType], bar: i32) -> String { ... } so probably to match that. I believe Haskell does something clever such that there is no difference between a function that takes two parameters, and a function that takes one parameter and returns a function that takes the second parameter. This isn't the case in Rust. Those would be distinct types and the latter would be called differently to the former. So I'm not sure that the Haskell syntax would work for Rust.