[Haskell-beginners] Function Type Confusion ..
Yitzchak Gale
gale at sefer.org
Tue Jan 27 13:31:23 EST 2009
Tom Poliquin wrote:
> add :: (b -> Int) -> (b -> Int) -> (b -> Int)
> add f g b = f b + g b
>
> The program compiles and runs and produces '19' !
>
> For fun I loaded into ghci and got what I believe is the proper
> type ..
>
> *Main> :t add
> add :: (b -> Int) -> (b -> Int) -> b -> Int
>
> When I try the same thing with something simpler
> (leaving a bit off the type definition)
> I get the expected error (by me) ..
In type expressions, the symbol -> is right-associative.
So
... -> (b -> Int)
is exactly the same as
... -> b -> Int
-Yitz
More information about the Beginners
mailing list