[Haskell-beginners] question from Yet Another Haskell Tutorial

Michael Mossey mpm at alumni.caltech.edu
Sun Mar 29 09:32:04 EDT 2009



Daniel Fischer wrote:
> A simple way to check for sanity of the results is:
> 
> Prelude> :t flip foldr 0 . flip. curry
> flip foldr 0 . flip. curry :: (Num c) => ((c, b) -> c) -> [b] -> c
> 
> Prelude> :t \f list -> foldr (\x y -> f (y,x)) 0 list
> \f list -> foldr (\x y -> f (y,x)) 0 list :: (Num b) =>
>                                              ((b, a) -> b) -> [a] -> b
> 
> Prelude> :t \f -> foldr (uncurry $ flip f) 0
> \f -> foldr (uncurry $ flip f) 0 :: (Num b1) =>
>                                     (b -> a -> b1 -> b1) -> [(a, b)] -> b1
> 
> So you see that your result has the correct type, while Hal's hasn't.
> 
>> Can anyone figure out what Hal is up to, or does it look like a simple
>> mistake?
> 
> Simple mistake. YAHT was never systematically proofread to catch all 
> such mistakes, so there are several still in. Nevertheless, it is an 
> excellent tutorial.

Thanks for the information, glad to know I was correct.

I agree that YAHT is excellent... I am working from several books and 
tutorials simultaneously to get various perspectives, and YAHT covers 
much of the same material as the books, but in a more compact form, with 
good exercises.

-Mike



More information about the Beginners mailing list