Skip to content

Why do we have both typeRep# and typeRep?

In Data.Typeable.Internal, we see

class Typeable (a :: k) where
  typeRep# :: TypeRep a

typeRep :: Typeable a => TypeRep a
typeRep = typeRep#

Why have typeRep separate from typeRep#? The only difference I can see is the specificity of the k variable. To wit, we have

typeRep# :: forall (k :: Type) (a :: k). Typeable @k a => TypeRep @k a
typeRep :: forall {k :: Type} (a :: k). Typeable @k a => TypeRep @k a

The only difference is the braces.

But we needn't do all this. Instead, we could define

class Typeable a where
  typeRep :: TypeRep a

It's unfortunate not to make that explicitly poly-kinded, but it would be inferred to be poly-kinded, and typeRep would get the right specificity.

So, is there anything stopping us from this simplification?

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