5 ms·
I don't understand one thing about this notation: fun :: A -> B -> C -> D can be bracketed in a bunch of different ways - fun1 :: (A -> B) -> (C -> D)
by zaptheimpaler 11y ago
I don't understand one thing about this notation:
fun :: A -> B -> C -> D
can be bracketed in a bunch of different ways -
fun1 :: (A -> B) -> (C -> D)
fun2 :: A -> (B -> C -> D)
etc. and don't these all mean different things?
fun1 would take a function and return a function, whereas fun2 takes an A and returns a curried function of B,C -> D.
- dwenzek 11y agoRead: fun :: A -> (B -> (C ->D))
- kryptiskt 11y agoYes, functions need to be bracketed, as they are single arguments with a complex type.
- Muphrid 11y agoThe order of operations here is "right associative". So A -> B -> C -> D is equivalent to any of the following A -> (B -> C -> D) A -> (B -> (C -> D)) A -> B -> (C -> D) They're equivalent through currying. But you can only add or remove parentheses for stuff that is on the right of a function arrow. (A -> B) -> (C -> D) is a different thing.