GHC performs useless worker-wrapper split
Consider this program:
module Hi where
data Identity a = Identity a
{-# NOINLINE unId #-}
unId :: Identity a -> a
unId (Identity a) = a
Since 9.0 (and possibly earlier) up to today, ghc -O
produces the following Core from this program:
-- RHS size: {terms: 3, types: 3, coercions: 0, joins: 0/0}
Hi.$wunId :: forall {a}. a -> a
Hi.$wunId = \ (@a_shr) (ww_shv :: a_shr) -> ww_shv
-- RHS size: {terms: 7, types: 8, coercions: 0, joins: 0/0}
unId :: forall a. Identity a -> a
unId
= \ (@a_shr) (w_shs :: Identity a_shr) ->
case w_shs of { Identity ww1_shv -> Hi.$wunId @a_shr ww1_shv }
I can think of absolutely no reason why this worker should exist.