functional composition in haskell
composition, haskell
Solution
The highest precedence in Haskell is function application or `f a`. So
fst . fst ((a, b), a)
is parsed as
fst . (fst ((a, b), a))
which is obviously nonsense. You can fix this with the `$` operator which is just function application with the lowest precedence, so `f $ a == f a`.
fst . fst $ ((a, b), a)
Or with some parens
(fst . fst) ((a, b), a)
Problem
How come I can't do ``` fst . fst (("Bob",12),10) ``` in Haskell? ``` :t fst . fst Prelude> ((c,b),b1) -> c ``` Doesn't this make (("Bob",12),10) a good candidate for fst . fst since it's ``` (([Char],Integer),Integer) ```