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)
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With