[Haskell-cafe] How can you effectively manually determine the type?

Anonymous Anonymous temp.public at gmail.com
Fri Feb 27 16:00:08 EST 2009


I'm new at haskell and I have the following question:

let's say I type the following:

function = foldr until

Now my first question is what is the type of this function? Well let's see
what the type of until and foldr is:

until :: (a -> Bool) -> (a -> a) -> a -> a
foldr :: (a -> b -> b) -> b -> [a] -> b

So I would be thinking: we fill until in the position of (a -> b -> b) so, a
correspond with (a -> Bool) and b correspond with (a -> a) and b correspond
with a. Hmm a small problem, I think we can divide that as follows: b1
corresponds with (a -> a) and b2 corresponds with a. So I get:

foldr until :: b1 -> [a] -> b2
foldr until :: (a -> a) -> [a -> Bool] -> a

Is this a correct way of thinking or am I wrong?

And another question is: can someone give me an example how this can be
executed? All my code that I tried to execute resulted in errors with "foldr

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090227/4bbd0949/attachment-0001.htm

More information about the Haskell-Cafe mailing list