change of strictness in zipWith

Henning Thielemann lemming at henning-thielemann.de
Fri Jan 2 09:50:51 UTC 2015


$ ghci-7.8.4 -Wall
Prelude> zipWith (==) "" undefined
[]

$ ghci-7.10.0.20141227 -Wall
Prelude> zipWith (==) "" undefined
*** Exception: Prelude.undefined


I found the difference because my mapAdjacent function uses 'tail' in the 
second argument of 'zipWith':

mapAdjacent :: (a -> a -> b) -> [a] -> [b]
mapAdjacent f xs = zipWith f xs (tail xs)


I get:

$ ghci-7.10.0.20141227 -Wall
*Prelude> Data.List.HT.mapAdjacent (==) ([] :: [Int])
*** Exception: Prelude.tail: empty list


More information about the Libraries mailing list