Skip to content

Check for fixed runtime rep fails unexpectedly when runtime rep is determined by default signature constraint.

I wondered if we could allow Unlifted instances for things like Eq and ran into this issues:

class Lifted a where
instance Lifted (a :: Type)

class Eq (a :: TYPE (BoxedRep r)) where
    (==) :: a -> a -> Bool
    (/=) ::  a -> a -> Bool
    default (/=) :: Lifted a => a -> a -> Bool
    (/=) x y = not $ x == y

Lifted constrains the default method to lifted types. And hence the runtime rep for the default method should be fixed. But I get this error:

Test.hs:24:5: error: [GHC-55287]
    The second pattern in the equation for ‘/=’
    does not have a fixed runtime representation.
    Its type is:
      a :: TYPE (BoxedRep r)
   |
24 |     (/=) x y = not $ x == y
   |     ^^^^^^^^^^^^^^^^^^^^^^^

I can't say I'm surprised that it doesn't work. But it would also be nice if it would work.

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