Author: Eiko

Tags: haskell, base, ghc

Time: 2024-10-15 15:11:22 - 2024-10-15 15:12:28 (UTC)

I’m exploring the GHC.List module and I’m learning a lot from it owo.

Inline

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

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