I'm having trouble understanding this simple snippet of code:
-- This works: foldr go1 [] [1..]
-- This doesn't: foldr go2 [] [1..]
go1 a b = a : b
go2 a [] = a : []
go2 a b = a : b
Folding with go1
immediately starts returning values, but go2
appears to be waiting for the end of the list.
Clearly the pattern matching is causing something to be handled differently. Can someone explain what exactly is going on here?