Type checking/inference

s_mazanek at gmx.de s_mazanek at gmx.de
Sun Dec 28 10:08:02 EST 2003


> prelude> :t map (foldr filter)
> map (foldr filter) :: [[a]] -> [[a -> Bool] -> [a]]
> Two main questions:
> 1/ How does hugs derive this answer?
> 2/ What input can I give so that it yields a correct result? I've tried 
> giving it a list of lists but it fails...


map (flip (foldr filter) [even,odd]) [[1,2,3],[4,5,6]]

I guess this meets your expectation.

Without flipping the arguments:
Prelude> map (foldr filter [1,2,3]) [[even]]
Prelude> map (foldr filter [1,2,3]) [[even],[even,odd]]
Prelude> map (foldr filter [1,2,3]) [[even],[even,odd],[odd]]


More information about the Haskell-Cafe mailing list