Use of function application operator in Haskell -
what following expression means in haskell?
($ 3)
ghci shows following type
($ 3) :: num => (a -> b) -> b.
($ 3)
section, , equivalent \f -> f 3
, takes function argument , applies 3.
if considered 3
integer, have type of f
int -> b
(for b
), type of ($ 3)
(int -> b) -> b
.
things in haskell bit more complex, since 3
can of numeric type, don't need f :: int -> b
, it's enough if f :: -> b
a
numeric type.
hence ($ 3) :: num => (a -> b) -> b
.
Comments
Post a Comment