Hacker News new | ask | show | jobs
by lytedev 2443 days ago
Looks like it denotes return type? Are you implying it can be omitted syntactically because the closing paren implies the return type would follow?
2 comments

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.

You mean like in Go?

    func add(x int, y int) int {
        return x + y
    }
I doubt this is more readable, but everyone has their own taste.