Commit 0e92af91 authored by Ryan Scott's avatar Ryan Scott
Browse files

Remove use of KProxy in GHC.Generics

Summary:
With `-XTypeInType`, the singletons machinery that `GHC.Generics` uses
no longer needs `KProxy` to hack around the use of `k` as both a type
and a kind. This is simply changing the code to match what's currently
in the upstream `singletons` repo.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: thomie, goldfire

Differential Revision: https://phabricator.haskell.org/D2347
parent 0be38a22
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
{-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE Trustworthy #-} {-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE UndecidableInstances #-}
...@@ -736,7 +737,7 @@ import GHC.Read ( Read(..), lex, readParen ) ...@@ -736,7 +737,7 @@ import GHC.Read ( Read(..), lex, readParen )
import GHC.Show ( Show(..), showString ) import GHC.Show ( Show(..), showString )
-- Needed for metadata -- Needed for metadata
import Data.Proxy ( Proxy(..), KProxy(..) ) import Data.Proxy ( Proxy(..) )
import GHC.TypeLits ( Nat, Symbol, KnownSymbol, KnownNat, symbolVal, natVal ) import GHC.TypeLits ( Nat, Symbol, KnownSymbol, KnownNat, symbolVal, natVal )
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
...@@ -1236,13 +1237,13 @@ class SingI (a :: k) where ...@@ -1236,13 +1237,13 @@ class SingI (a :: k) where
-- | The 'SingKind' class is essentially a /kind/ class. It classifies all kinds -- | The 'SingKind' class is essentially a /kind/ class. It classifies all kinds
-- for which singletons are defined. The class supports converting between a singleton -- for which singletons are defined. The class supports converting between a singleton
-- type and the base (unrefined) type which it is built from. -- type and the base (unrefined) type which it is built from.
class (kparam ~ 'KProxy) => SingKind (kparam :: KProxy k) where class SingKind k where
-- | Get a base type from a proxy for the promoted kind. For example, -- | Get a base type from a proxy for the promoted kind. For example,
-- @DemoteRep ('KProxy :: KProxy Bool)@ will be the type @Bool@. -- @DemoteRep Bool@ will be the type @Bool@.
type DemoteRep kparam :: * type DemoteRep k :: *
-- | Convert a singleton to its unrefined version. -- | Convert a singleton to its unrefined version.
fromSing :: Sing (a :: k) -> DemoteRep kparam fromSing :: Sing (a :: k) -> DemoteRep k
-- Singleton symbols -- Singleton symbols
data instance Sing (s :: Symbol) where data instance Sing (s :: Symbol) where
...@@ -1252,8 +1253,8 @@ data instance Sing (s :: Symbol) where ...@@ -1252,8 +1253,8 @@ data instance Sing (s :: Symbol) where
instance KnownSymbol a => SingI a where sing = SSym instance KnownSymbol a => SingI a where sing = SSym
-- | @since 4.9.0.0 -- | @since 4.9.0.0
instance SingKind ('KProxy :: KProxy Symbol) where instance SingKind Symbol where
type DemoteRep ('KProxy :: KProxy Symbol) = String type DemoteRep Symbol = String
fromSing (SSym :: Sing s) = symbolVal (Proxy :: Proxy s) fromSing (SSym :: Sing s) = symbolVal (Proxy :: Proxy s)
-- Singleton booleans -- Singleton booleans
...@@ -1268,8 +1269,8 @@ instance SingI 'True where sing = STrue ...@@ -1268,8 +1269,8 @@ instance SingI 'True where sing = STrue
instance SingI 'False where sing = SFalse instance SingI 'False where sing = SFalse
-- | @since 4.9.0.0 -- | @since 4.9.0.0
instance SingKind ('KProxy :: KProxy Bool) where instance SingKind Bool where
type DemoteRep ('KProxy :: KProxy Bool) = Bool type DemoteRep Bool = Bool
fromSing STrue = True fromSing STrue = True
fromSing SFalse = False fromSing SFalse = False
...@@ -1285,10 +1286,8 @@ instance SingI 'Nothing where sing = SNothing ...@@ -1285,10 +1286,8 @@ instance SingI 'Nothing where sing = SNothing
instance SingI a => SingI ('Just a) where sing = SJust sing instance SingI a => SingI ('Just a) where sing = SJust sing
-- | @since 4.9.0.0 -- | @since 4.9.0.0
instance SingKind ('KProxy :: KProxy a) => instance SingKind a => SingKind (Maybe a) where
SingKind ('KProxy :: KProxy (Maybe a)) where type DemoteRep (Maybe a) = Maybe (DemoteRep a)
type DemoteRep ('KProxy :: KProxy (Maybe a)) =
Maybe (DemoteRep ('KProxy :: KProxy a))
fromSing SNothing = Nothing fromSing SNothing = Nothing
fromSing (SJust a) = Just (fromSing a) fromSing (SJust a) = Just (fromSing a)
...@@ -1305,8 +1304,8 @@ instance (SingI a, KnownNat n) => SingI ('InfixI a n) where ...@@ -1305,8 +1304,8 @@ instance (SingI a, KnownNat n) => SingI ('InfixI a n) where
sing = SInfix (sing :: Sing a) (natVal (Proxy :: Proxy n)) sing = SInfix (sing :: Sing a) (natVal (Proxy :: Proxy n))
-- | @since 4.9.0.0 -- | @since 4.9.0.0
instance SingKind ('KProxy :: KProxy FixityI) where instance SingKind FixityI where
type DemoteRep ('KProxy :: KProxy FixityI) = Fixity type DemoteRep FixityI = Fixity
fromSing SPrefix = Prefix fromSing SPrefix = Prefix
fromSing (SInfix a n) = Infix (fromSing a) (I# (integerToInt n)) fromSing (SInfix a n) = Infix (fromSing a) (I# (integerToInt n))
...@@ -1326,8 +1325,8 @@ instance SingI 'RightAssociative where sing = SRightAssociative ...@@ -1326,8 +1325,8 @@ instance SingI 'RightAssociative where sing = SRightAssociative
instance SingI 'NotAssociative where sing = SNotAssociative instance SingI 'NotAssociative where sing = SNotAssociative
-- | @since 4.0.0.0 -- | @since 4.0.0.0
instance SingKind ('KProxy :: KProxy Associativity) where instance SingKind Associativity where
type DemoteRep ('KProxy :: KProxy Associativity) = Associativity type DemoteRep Associativity = Associativity
fromSing SLeftAssociative = LeftAssociative fromSing SLeftAssociative = LeftAssociative
fromSing SRightAssociative = RightAssociative fromSing SRightAssociative = RightAssociative
fromSing SNotAssociative = NotAssociative fromSing SNotAssociative = NotAssociative
...@@ -1348,8 +1347,8 @@ instance SingI 'SourceNoUnpack where sing = SSourceNoUnpack ...@@ -1348,8 +1347,8 @@ instance SingI 'SourceNoUnpack where sing = SSourceNoUnpack
instance SingI 'SourceUnpack where sing = SSourceUnpack instance SingI 'SourceUnpack where sing = SSourceUnpack
-- | @since 4.9.0.0 -- | @since 4.9.0.0
instance SingKind ('KProxy :: KProxy SourceUnpackedness) where instance SingKind SourceUnpackedness where
type DemoteRep ('KProxy :: KProxy SourceUnpackedness) = SourceUnpackedness type DemoteRep SourceUnpackedness = SourceUnpackedness
fromSing SNoSourceUnpackedness = NoSourceUnpackedness fromSing SNoSourceUnpackedness = NoSourceUnpackedness
fromSing SSourceNoUnpack = SourceNoUnpack fromSing SSourceNoUnpack = SourceNoUnpack
fromSing SSourceUnpack = SourceUnpack fromSing SSourceUnpack = SourceUnpack
...@@ -1370,8 +1369,8 @@ instance SingI 'SourceLazy where sing = SSourceLazy ...@@ -1370,8 +1369,8 @@ instance SingI 'SourceLazy where sing = SSourceLazy
instance SingI 'SourceStrict where sing = SSourceStrict instance SingI 'SourceStrict where sing = SSourceStrict
-- | @since 4.9.0.0 -- | @since 4.9.0.0
instance SingKind ('KProxy :: KProxy SourceStrictness) where instance SingKind SourceStrictness where
type DemoteRep ('KProxy :: KProxy SourceStrictness) = SourceStrictness type DemoteRep SourceStrictness = SourceStrictness
fromSing SNoSourceStrictness = NoSourceStrictness fromSing SNoSourceStrictness = NoSourceStrictness
fromSing SSourceLazy = SourceLazy fromSing SSourceLazy = SourceLazy
fromSing SSourceStrict = SourceStrict fromSing SSourceStrict = SourceStrict
...@@ -1392,8 +1391,8 @@ instance SingI 'DecidedStrict where sing = SDecidedStrict ...@@ -1392,8 +1391,8 @@ instance SingI 'DecidedStrict where sing = SDecidedStrict
instance SingI 'DecidedUnpack where sing = SDecidedUnpack instance SingI 'DecidedUnpack where sing = SDecidedUnpack
-- | @since 4.9.0.0 -- | @since 4.9.0.0
instance SingKind ('KProxy :: KProxy DecidedStrictness) where instance SingKind DecidedStrictness where
type DemoteRep ('KProxy :: KProxy DecidedStrictness) = DecidedStrictness type DemoteRep DecidedStrictness = DecidedStrictness
fromSing SDecidedLazy = DecidedLazy fromSing SDecidedLazy = DecidedLazy
fromSing SDecidedStrict = DecidedStrict fromSing SDecidedStrict = DecidedStrict
fromSing SDecidedUnpack = DecidedUnpack fromSing SDecidedUnpack = DecidedUnpack
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment