{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeAbstractions #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Data.Proxy.Singletons (
Sing, SProxy(..)
, AsProxyTypeOf, sAsProxyTypeOf
, ProxySym0
, AsProxyTypeOfSym0, AsProxyTypeOfSym1, AsProxyTypeOfSym2
) where
import Control.Applicative
import Control.Monad
import Control.Monad.Singletons.Internal
import Data.Eq.Singletons
import Data.Monoid.Singletons
import Data.Ord.Singletons
import Data.Proxy
import Data.Semigroup (Semigroup(..))
import Data.Semigroup.Singletons.Internal.Classes
import Data.Singletons.Decide
import Data.Singletons.Base.Enum
import Data.Singletons.Base.Instances
import Data.Singletons.TH
import Data.Singletons.TH.Options
import Data.Type.Coercion
import Data.Type.Equality hiding (type (==))
import GHC.Base.Singletons
import GHC.Num.Singletons
import GHC.TypeLits.Singletons.Internal
import Text.Show.Singletons
$(withOptions defaultOptions{genSingKindInsts = False}
(genSingletons [''Proxy]))
instance SingKind (Proxy t) where
type Demote (Proxy t) = Proxy t
fromSing :: forall (a :: Proxy t). Sing a -> Demote (Proxy t)
fromSing Sing a
SProxy a
SProxy = Proxy t
Demote (Proxy t)
forall {k} (t :: k). Proxy t
Proxy
toSing :: Demote (Proxy t) -> SomeSing (Proxy t)
toSing Proxy t
Demote (Proxy t)
Proxy = Sing 'Proxy -> SomeSing (Proxy t)
forall k (a :: k). Sing a -> SomeSing k
SomeSing Sing 'Proxy
SProxy 'Proxy
forall {k} (t :: k). SProxy 'Proxy
SProxy
instance Eq (SProxy z) where
SProxy z
_ == :: SProxy z -> SProxy z -> Bool
== SProxy z
_ = Bool
True
instance SDecide (Proxy t) where
Sing a
SProxy a
SProxy %~ :: forall (a :: Proxy t) (b :: Proxy t).
Sing a -> Sing b -> Decision (a :~: b)
%~ Sing b
SProxy b
SProxy = (a :~: b) -> Decision (a :~: b)
forall a. a -> Decision a
Proved a :~: a
a :~: b
forall {k} (a :: k). a :~: a
Refl
instance TestEquality SProxy where
testEquality :: forall (a :: Proxy t) (b :: Proxy t).
SProxy a -> SProxy b -> Maybe (a :~: b)
testEquality = Sing a -> Sing b -> Maybe (a :~: b)
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 :: forall (a :: Proxy t) (b :: Proxy t).
SProxy a -> SProxy b -> Maybe (Coercion a b)
testCoercion = Sing a -> Sing b -> Maybe (Coercion a b)
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 Ord (SProxy z) where
compare :: SProxy z -> SProxy z -> Ordering
compare SProxy z
_ SProxy z
_ = Ordering
EQ
instance Show (SProxy z) where
showsPrec :: Int -> SProxy z -> ShowS
showsPrec Int
_ SProxy z
_ = String -> ShowS
showString String
"SProxy"
$