swap foldr args to match haskell behavior