I’m exploring the GHC.List module and I’m learning a lot from it owo.
Inline can only happen if the parameters are saturated, so you should do eta-reduction as much as possible or use lambda expressions at times (when the special cases are needed) to enable inlining.
build :: (forall b. (a -> b -> b) -> b -> b) -> [a]
build g = g (:) []
{-# INLINE [1] build #-}
augment g xs = g (:) xs
{-# INLINE [1] augment #-}this function accepts a list builder who takes a list constructor and a tail, returning a list.
The list constructor is left out in g to make list fusion with foldr possible