Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#11775 closed bug (invalid)

singleton classes in ghc.generics are defined but not exported

Reported by: carter Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.0.1-rc2
Keywords: Generics Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


I noticed in the bottom of the GHC.Generics module in the RC candidate that theres some type classea and instnaces involving singletons included and notated as copied from the singletons package but not exported

-- Copied from the singletons package

-- | The singleton kind-indexed data family.
data family Sing (a :: k)

-- | A 'SingI' constraint is essentially an implicitly-passed singleton.
-- If you need to satisfy this constraint with an explicit singleton, please
-- see 'withSingI'.
class SingI (a :: k) where
  -- | Produce the singleton explicitly. You will likely need the @ScopedTypeVariables@
  -- extension to use this method the way you want.
  sing :: Sing a

-- | The 'SingKind' class is essentially a /kind/ class. It classifies all kinds
-- for which singletons are defined. The class supports converting between a singleton
-- type and the base (unrefined) type which it is built from.
class (kparam ~ 'KProxy) => SingKind (kparam :: KProxy k) where
  -- | Get a base type from a proxy for the promoted kind. For example,
  -- @DemoteRep ('KProxy :: KProxy Bool)@ will be the type @Bool@.
  type DemoteRep kparam :: *

  -- | Convert a singleton to its unrefined version.
  fromSing :: Sing (a :: k) -> DemoteRep kparam

etc, is this deliberate?

Change History (3)

comment:1 Changed 4 years ago by bgamari

Yes, these are intentional. They are used in instances defined in GHC.Generics. e.g.,

     instance (KnownSymbol n, SingI f, SingI r)
         => Constructor ('MetaCons n f r) where
       conName     _ = symbolVal (Proxy :: Proxy n)
       conFixity   _ = fromSing  (sing  :: Sing f)
       conIsRecord _ = fromSing  (sing  :: Sing r)
Last edited 4 years ago by bgamari (previous) (diff)

comment:2 Changed 4 years ago by bgamari

Resolution: invalid
Status: newclosed

comment:3 Changed 4 years ago by RyanGlScott

Keywords: Generics added
Note: See TracTickets for help on using tickets.