Open johnynek opened 1 year ago
The tactic here, I guess would be to have a few stages:
build_List
or foldr_List
(e.g. map_List, filter_List, concat_List, etc...)foldr_List(build_List(g), a, b) == g(a, b)
optimizationfoldr_List
into fold-left and reverse.
See the foldr/build optimization here:
https://users.cs.northwestern.edu/~robby/courses/395-495-2017-winter/deforestation-short-cut.pdf
And Wadler's paper:
https://homepages.inf.ed.ac.uk/wadler/papers/deforest/deforest.ps