{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Data.Singletons.Prelude.Proxy (
Sing, SProxy(..)
, AsProxyTypeOf, sAsProxyTypeOf
, ProxySym0
, AsProxyTypeOfSym0, AsProxyTypeOfSym1, AsProxyTypeOfSym2
) where
import Control.Applicative
import Control.Monad
import Data.Kind
import Data.Proxy
import Data.Semigroup (Semigroup(..))
import Data.Singletons.Decide
import Data.Singletons.Internal
import Data.Singletons.Prelude.Base
import Data.Singletons.Prelude.Enum
import Data.Singletons.Prelude.Eq
import Data.Singletons.Prelude.Instances
import Data.Singletons.Prelude.Monad.Internal
import Data.Singletons.Prelude.Monoid
import Data.Singletons.Prelude.Ord
import Data.Singletons.Prelude.Semigroup.Internal
import Data.Singletons.Prelude.Show
import Data.Singletons.Promote
import Data.Singletons.Single
import Data.Singletons.TypeLits.Internal
import Data.Type.Coercion
import Data.Type.Equality hiding (type (==))
data SProxy :: forall t. Proxy t -> Type where
SProxy :: forall t. SProxy ('Proxy @t)
type instance Sing = SProxy
instance SingKind (Proxy t) where
type Demote (Proxy t) = Proxy t
fromSing :: Sing a -> Demote (Proxy t)
fromSing Sing a
SProxy = Demote (Proxy t)
forall k (t :: k). Proxy t
Proxy
toSing :: Demote (Proxy t) -> SomeSing (Proxy t)
toSing Demote (Proxy t)
Proxy = Sing 'Proxy -> SomeSing (Proxy t)
forall k (a :: k). Sing a -> SomeSing k
SomeSing Sing 'Proxy
forall k (t :: k). SProxy 'Proxy
SProxy
instance SingI 'Proxy where
sing :: Sing 'Proxy
sing = Sing 'Proxy
forall k (t :: k). SProxy 'Proxy
SProxy
$(genDefunSymbols [''Proxy])
instance SDecide (Proxy t) where
Sing a
SProxy %~ :: Sing a -> Sing b -> Decision (a :~: b)
%~ Sing b
SProxy = (a :~: a) -> Decision (a :~: a)
forall a. a -> Decision a
Proved a :~: a
forall k (a :: k). a :~: a
Refl
instance TestEquality SProxy where
testEquality :: SProxy a -> SProxy b -> Maybe (a :~: b)
testEquality = SProxy a -> SProxy b -> Maybe (a :~: b)
forall k (a :: k) (b :: k).
SDecide k =>
Sing a -> Sing b -> Maybe (a :~: b)
decideEquality
instance TestCoercion SProxy where
testCoercion :: SProxy a -> SProxy b -> Maybe (Coercion a b)
testCoercion = SProxy a -> SProxy b -> Maybe (Coercion a b)
forall k (a :: k) (b :: k).
SDecide k =>
Sing a -> Sing b -> Maybe (Coercion a b)
decideCoercion
instance Show (SProxy z) where
showsPrec :: Int -> SProxy z -> ShowS
showsPrec Int
_ SProxy z
_ = String -> ShowS
showString String
"SProxy"
$(