Skip to content

Newly added Constraint in Specialize Pragma prints warning with Uniques in them

Example:

-- Redundant constraint in specialize pragma.
-- Also generates an unrelated warning:
-- > Forall'd constraint ‘Eq a’ is not bound in RULE lhs
{-# SPECIALISE spec :: Eq a => a -> Int -> Int #-}

spec :: Ord b => a -> b -> b
spec _ b
    | b <= b = b
    | otherwise = b

Prints the following warning:

T19296.hs:4:1: warning:
    Forall'd constraint ‘Eq a’ is not bound in RULE lhs
      Orig bndrs: [a, $dEq_a15Z]
      Orig lhs: let {
                  $dOrd_a162 :: Ord Int
                  [LclId]
                  $dOrd_a162 = GHC.Classes.$fOrdInt } in
                spec @Int @a $dOrd_a162
      optimised lhs: spec @Int @a $dOrd_a162
   |
21 | {-# SPECIALISE spec :: Eq a => a -> Int -> Int #-}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The warning contains Unique's which are different on each platform, the warning is thus unstable and additionally hard to read.

Would be nice if we could improve that.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information