I don't think it makes sense to say `fn read(s: string) -> int` as in Rust though. If an arrow were used in such a function declaration, it should probably look something more like:
fn read: (s: string) -> int
As another commenter has indicated, `fn read(s: string): int` states that `read(s)` is of type `int`, which is logical.
The thing about adopting the ASCII Art pseudo arrow is that it bakes in an assumption that the dash character lines up vertically with the point on the angle bracket character. This simply isn't the case in plenty of fonts. So it often looks like crap if you pay attention.
Which fonts does it not look good in? Haskell, Rust, Swift, Ocaml, and I'm sure some others, all use this notation. And I've never seen the '->' look odd in any font I've ever used.
I just went to the Rust homepage and clicked until I found an example of a function. It's being presented in Monaco where the dash is noticeably higher than the centre of the angle bracket.
Depends on the language but in Haskell, the (->) arrow is a function type constructor (i.e. constructs function at type level) where a -> b constructs a function type from a to b.
This is often chained to produce functions that 'take multiple arguments'. i.e. a -> b -> b. I put that in quotations because in reality all functions take only one argument, this is called currying. It gives functions flexibility in that you can partially apply them at will.
In languages like Rust and Swift, the syntax is (a: A, b: B) -> B. Because these languages are "uncurried", they use the syntax of uncurried functions. Meaning, they cannot be readily partially applied.
A function of type `Int -> String` allows you to get a `String` from an `Int`.
The proposition `A -> B` (`A` implies `B`) means that `A` being true allows `B` to be true; we can deduce `B` from `A`.
For the link between functions and implication, see: https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspon...
I don't think it makes sense to say `fn read(s: string) -> int` as in Rust though. If an arrow were used in such a function declaration, it should probably look something more like:
As another commenter has indicated, `fn read(s: string): int` states that `read(s)` is of type `int`, which is logical.