[Haskell-beginners] Question regarding infering the type of a function

MoC moc at coders-haven.net
Mon Sep 21 17:06:37 EDT 2009


Daniel Fischer wrote:
>
> (v -> w) -> (u -> v) -> u -> w === (v -> w) -> ((u -> v) -> (u -> w))
>
> Feeding it as an argument to the first, we must unify this type with the type of the first 
> (.)'s (first) argument, (b -> c), thus
>
> b = (v -> w)
> c = (u -> v) -> u -> w
>
> and the type of (.) (.) becomes (a -> b) -> a -> c, which is
>
> (a -> (v -> w)) -> a -> ((u -> v) -> u -> w)
>
> by what we got for b and c.
I started with the same approach but for whatever reason failed to see 
the "feeding" process so I basically said that
    b = (v -> w) -> ((u -> v) -> (u -> w))
which, of course, was a dead end. It's interesting that I did not have 
problems with acknowledging a feeding process with "simple" (for I don't 
know the proper term) types, e. g. it was clear to me that if I feed
    f :: (a->b)->c
with
    g :: Integer -> Integer
a and b in this case would be Integer in this case. I think I'm not 
completely used to functions being value, yet. ;)

Anyway, thank you very much for helping out (actually to both replies) 
and in this case also for clarifying.


Regards,
    MoC


More information about the Beginners mailing list