Skip to content

Typeable appears not to work with UnboxedSums

This program fails to compile:

{-# LANGUAGE UnboxedSums, UnboxedTuples #-}                                     
                                                                                
module Test where                                                               
                                                                                
import Data.Proxy                                                               
import Type.Reflection                                                          
                                                                                
main = do                                                                       
  print (someTypeRep (Proxy @(# () , () #)))                                    
  print (someTypeRep (Proxy @(# () | () #)))                                    

with error:


Unboxed.hs:10:10: error: [GHC-39999]
    • No instance for ‘Typeable (# | #)’
        arising from a use of ‘someTypeRep’
        GHC can't yet do polykinded
          Typeable ((# | #) :: *
                               -> *
                               -> TYPE
                                    (GHC.Types.SumRep [GHC.Types.LiftedRep, GHC.Types.LiftedRep]))
    • In the first argument of ‘print’, namely
        ‘(someTypeRep (Proxy @(# () | () #)))’
      In a stmt of a 'do' block:
        print (someTypeRep (Proxy @(# () | () #)))
      In the expression:
        do print (someTypeRep (Proxy @(# (), () #)))
           print (someTypeRep (Proxy @(# () | () #)))
   |
10 |   print (someTypeRep (Proxy @(# () | () #)))
   |          ^^^^^^^^^^^

If it works for unboxed tuples then I expected the same to work for unboxed sums.

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