Standard classes and unlifted user types

Hi,

I try new features from GHC 9.2. One of them is unlifted boxed user defined data types. I noticed that I cannot instantiate Show class for type.

:i Show
type Show :: * -> Constraint
class Show a where
...

I see obvious Show still accepts only lifted types (* is Type).
I haven’t found any reference related to the problem of reusing existing classes for unlifted types in the extension proposal.

What is the default recipe for such scenario?
Should define or look for Show counterpart class prefixed with S i.e. SShow?

    • Expecting a lifted type, but ‘MyUnliftedBoxed’ is unlifted
    • In the first argument of ‘Show’, namely ‘MyUnliftedBoxed’
      In the instance declaration for ‘Show MyUnliftedBoxed’
   |
14 | instance Show MyUnliftedBoxed where

GHC doesn’t suggest anything.


Update:

I see Show class should be levity polymorphic, but it isn’t.
So rephrasing my original question - why standard classes are not levity polymorphic?

2 Likes

See:

There is a library that implements these levity-polymorphic type classes: unboxed.

2 Likes