((c,b),b1) -> c Does tha...">

Functional composition in haskell

Why i can't do

fst . fst (("Bob",12),10)

in Haskell?

:t fst . fst
Prelude> ((c,b),b1) -> c

Does that make (("Bob", 12), 10) a good candidate for fst. fst since this

(([Char],Integer),Integer)
+4
source share
1 answer

Haskell's highest priority is the function application or f a. So

fst . fst ((a, b), a)

analyzed as

fst . (fst ((a, b), a))

which is obviously pointless. You can fix this with an operator $, which is just a functional application with the lowest priority, therefore f $ a == f a.

fst . fst $ ((a, b), a)

Or with some parens

(fst . fst) ((a, b), a)
+8
source

All Articles