Avoiding construction of dead dictionaries

Michael Sperber sperber at deinprogramm.de
Fri Aug 6 13:06:15 UTC 2021


I have another optimization problem.  ConCat includes this definition:

(<+) :: Con a => (Con b => r) -> (a |- b) -> r
r <+ Entail (Sub Dict) = r

The right-hand argument of <+ leads to a dictionary construction that is
a proof of a certain property, but the dictionary itself ends up being
dead, like so:

      case $w$dOpCon_r2kGJ ...
      of
      { (# ww1_s27L3 #) -> ... }
           ^^^^^^^^^
           never used

Yet, ghc (8.10.4) never elides this code.  (I'm naively assuming because
of the unboxed tuple, but actually have no clue.)

Is there any chance of convincing ghc of erasing the dictionary
construction?

Help would be much appreciated!

-- 
Regards,
Mike



More information about the Glasgow-haskell-users mailing list