Would it not be unsound for ghc to elide dictionary construction here? After all, the right-hand side might actually be a bottom (e.g. undefined) at run-time, in which case the pattern match cannot succeed according to the semantics of Haskell. I suspect that if you make the pattern match lazy (i.e. ~(Entail (Sub Dict))) or ignore the argument altogether (i.e. _), dictionary construction will be elided.
I have another optimization problem. ConCat includes this definition:(<+) :: Con a => (Con b => r) -> (a |- b) -> r
r <+ Entail (Sub Dict) = rThe 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 usedYet, 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_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users