If I have this insert function:
insert x [] = [x]
insert x (h:t)
| x <= h = x:(h:t)
| otherwise = h:(insert x t)
this produces a sorted list:
foldr insert [] [1,19,-2,7,43]
but this:
foldr1 insert [1,19,-2,7,43]
produces 'cannot construct the infinite type: a0 = [a0]'
I'm confused about why the second call cannot work.
I have looked at the definitions for both foldr and foldr1 and have traced both with simple arithmetic functions, but I still cannot come up with a clear explanation for why the second call fails.