Skip to content
  • Simon Peyton Jones's avatar
    Export a tiny bit more info with AbstractTyCon (fixes #5424) · de9b85fa
    Simon Peyton Jones authored
    When we compile -O0 we put type constructors in the interface file
    without their data constructors -- an AbstractTyCon.  But in a
    client module, to give good pattern-match exhaustiveness warnings,
    we need to know the difference between a data type and a newtype.
    (The latter can be coerced to another type, but a data type can't.)
    See Note [Pruning dead case alternatives] in Unify.
    
    Because we weren't conveying this info, we were getting bogus
    warnings about inexhaustive patterm matches with GADTs, and
    (confusingly) these warnings woudl come and go depending on
    whether you were compiling with -O.
    
    This patch makes AbstractTyCon carry a flag indicating whether
    the type constructor is "distinct"; two distinct TyCons cannot
    be coerced into eachother (except by unsafeCoerce, in which case
    all bets are off).
    
    HEADS UP: interface file format changes slightly, so you need
    to make clean.
    de9b85fa