{-# LANGUAGE MagicHash, RankNTypes, PolyKinds, GADTs, DataKinds,
FlexibleContexts, FlexibleInstances,
TypeFamilies, TypeOperators, TypeFamilyDependencies,
UndecidableInstances, ConstraintKinds,
ScopedTypeVariables, TypeApplications, AllowAmbiguousTypes,
PatternSynonyms, ViewPatterns #-}
module Data.Singletons.Internal (
module Data.Singletons.Internal
, Proxy(..)
) where
import Data.Kind (Type)
import Unsafe.Coerce
import Data.Proxy ( Proxy(..) )
import GHC.Exts ( Proxy#, Constraint )
type KindOf (a :: k) = k
type SameKind (a :: k) (b :: k) = (() :: Constraint)
type family Sing :: k -> Type
class SingI a where
sing :: Sing a
{-# COMPLETE Sing #-}
pattern Sing :: forall k (a :: k). () => SingI a => Sing a
pattern $bSing :: Sing a
$mSing :: forall r k (a :: k). Sing a -> (SingI a => r) -> (Void# -> r) -> r
Sing <- (singInstance -> SingInstance)
where Sing = Sing a
forall k (a :: k). SingI a => Sing a
sing
class SingKind k where
type Demote k = (r :: Type) | r -> k
fromSing :: Sing (a :: k) -> Demote k
toSing :: Demote k -> SomeSing k
data SomeSing k where
SomeSing :: Sing (a :: k) -> SomeSing k
{-# COMPLETE FromSing #-}
pattern FromSing :: SingKind k => forall (a :: k). Sing a -> Demote k
pattern $bFromSing :: Sing a -> Demote k
$mFromSing :: forall r k.
SingKind k =>
Demote k -> (forall (a :: k). Sing a -> r) -> (Void# -> r) -> r
FromSing sng <- ((\demotedVal -> withSomeSing demotedVal SomeSing) -> SomeSing sng)
where FromSing sng :: Sing a
sng = Sing a -> Demote k
forall k (a :: k). SingKind k => Sing a -> Demote k
fromSing Sing a
sng
newtype WrappedSing :: forall k. k -> Type where
WrapSing :: forall k (a :: k). { WrappedSing a -> Sing a
unwrapSing :: Sing a } -> WrappedSing a
newtype SWrappedSing :: forall k (a :: k). WrappedSing a -> Type where
SWrapSing :: forall k (a :: k) (ws :: WrappedSing a).
{ SWrappedSing ws -> Sing a
sUnwrapSing :: Sing a } -> SWrappedSing ws
type instance Sing = SWrappedSing
type family UnwrapSing (ws :: WrappedSing a) :: Sing a where
UnwrapSing ('WrapSing s) = s
instance SingKind (WrappedSing a) where
type Demote (WrappedSing a) = WrappedSing a
fromSing :: Sing a -> Demote (WrappedSing a)
fromSing (SWrapSing s) = Sing a -> WrappedSing a
forall k (a :: k). Sing a -> WrappedSing a
WrapSing Sing a
s
toSing :: Demote (WrappedSing a) -> SomeSing (WrappedSing a)
toSing (WrapSing s) = Sing Any -> SomeSing (WrappedSing a)
forall k (a :: k). Sing a -> SomeSing k
SomeSing (Sing Any -> SomeSing (WrappedSing a))
-> Sing Any -> SomeSing (WrappedSing a)
forall a b. (a -> b) -> a -> b
$ Sing a -> SWrappedSing Any
forall k (a :: k) (ws :: WrappedSing a). Sing a -> SWrappedSing ws
SWrapSing Sing a
s
instance forall a (s :: Sing a). SingI a => SingI ('WrapSing s) where
sing :: Sing ('WrapSing s)
sing = Sing a -> SWrappedSing ('WrapSing s)
forall k (a :: k) (ws :: WrappedSing a). Sing a -> SWrappedSing ws
SWrapSing Sing a
forall k (a :: k). SingI a => Sing a
sing
data SingInstance (a :: k) where
SingInstance :: SingI a => SingInstance a
newtype DI a = Don'tInstantiate (SingI a => SingInstance a)
singInstance :: forall k (a :: k). Sing a -> SingInstance a
singInstance :: Sing a -> SingInstance a
singInstance s :: Sing a
s = (SingI a => SingInstance a) -> SingInstance a
with_sing_i SingI a => SingInstance a
forall k (a :: k). SingI a => SingInstance a
SingInstance
where
with_sing_i :: (SingI a => SingInstance a) -> SingInstance a
with_sing_i :: (SingI a => SingInstance a) -> SingInstance a
with_sing_i si :: SingI a => SingInstance a
si = DI a -> Sing a -> SingInstance a
forall a b. a -> b
unsafeCoerce ((SingI a => SingInstance a) -> DI a
forall k (a :: k). (SingI a => SingInstance a) -> DI a
Don'tInstantiate SingI a => SingInstance a
si) Sing a
s
data TyFun :: Type -> Type -> Type
type a ~> b = TyFun a b -> Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
type a @@ b = Apply a b
infixl 9 @@
data family TyCon :: (k1 -> k2) -> unmatchable_fun
type family ApplyTyCon :: (k1 -> k2) -> (k1 ~> unmatchable_fun) where
ApplyTyCon @k1 @(k2 -> k3) @unmatchable_fun = ApplyTyConAux2
ApplyTyCon @k1 @k2 @k2 = ApplyTyConAux1
type instance Apply (TyCon f) x = ApplyTyCon f @@ x
data ApplyTyConAux1 :: (k1 -> k2) -> (k1 ~> k2)
data ApplyTyConAux2 :: (k1 -> k2 -> k3) -> (k1 ~> unmatchable_fun)
type instance Apply (ApplyTyConAux1 f) x = f x
type instance Apply (ApplyTyConAux2 f) x = TyCon (f x)
type TyCon1 = (TyCon :: (k1 -> k2) -> (k1 ~> k2))
type TyCon2 = (TyCon :: (k1 -> k2 -> k3) -> (k1 ~> k2 ~> k3))
type TyCon3 = (TyCon :: (k1 -> k2 -> k3 -> k4) -> (k1 ~> k2 ~> k3 ~> k4))
type TyCon4 = (TyCon :: (k1 -> k2 -> k3 -> k4 -> k5) -> (k1 ~> k2 ~> k3 ~> k4 ~> k5))
type TyCon5 = (TyCon :: (k1 -> k2 -> k3 -> k4 -> k5 -> k6)
-> (k1 ~> k2 ~> k3 ~> k4 ~> k5 ~> k6))
type TyCon6 = (TyCon :: (k1 -> k2 -> k3 -> k4 -> k5 -> k6 -> k7)
-> (k1 ~> k2 ~> k3 ~> k4 ~> k5 ~> k6 ~> k7))
type TyCon7 = (TyCon :: (k1 -> k2 -> k3 -> k4 -> k5 -> k6 -> k7 -> k8)
-> (k1 ~> k2 ~> k3 ~> k4 ~> k5 ~> k6 ~> k7 ~> k8))
type TyCon8 = (TyCon :: (k1 -> k2 -> k3 -> k4 -> k5 -> k6 -> k7 -> k8 -> k9)
-> (k1 ~> k2 ~> k3 ~> k4 ~> k5 ~> k6 ~> k7 ~> k8 ~> k9))
newtype SLambda (f :: k1 ~> k2) =
SLambda { SLambda f -> forall (t :: k1). Sing t -> Sing (f @@ t)
applySing :: forall t. Sing t -> Sing (f @@ t) }
type instance Sing = SLambda
(@@) :: forall k1 k2 (f :: k1 ~> k2) (t :: k1). Sing f -> Sing t -> Sing (f @@ t)
@@ :: Sing f -> Sing t -> Sing (f @@ t)
(@@) = Sing f -> Sing t -> Sing (f @@ t)
forall k1 k2 (f :: k1 ~> k2).
SLambda f -> forall (t :: k1). Sing t -> Sing (f @@ t)
applySing
instance (SingKind k1, SingKind k2) => SingKind (k1 ~> k2) where
type Demote (k1 ~> k2) = Demote k1 -> Demote k2
fromSing :: Sing a -> Demote (k1 ~> k2)
fromSing sFun :: Sing a
sFun x :: Demote k1
x = Demote k1 -> (forall (a :: k1). Sing a -> Demote k2) -> Demote k2
forall k r.
SingKind k =>
Demote k -> (forall (a :: k). Sing a -> r) -> r
withSomeSing Demote k1
x (Sing (Apply a a) -> Demote k2
forall k (a :: k). SingKind k => Sing a -> Demote k
fromSing (Sing (Apply a a) -> Demote k2)
-> (Sing a -> Sing (Apply a a)) -> Sing a -> Demote k2
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SLambda a -> forall (t :: k1). Sing t -> Sing (a @@ t)
forall k1 k2 (f :: k1 ~> k2).
SLambda f -> forall (t :: k1). Sing t -> Sing (f @@ t)
applySing SLambda a
Sing a
sFun)
toSing :: Demote (k1 ~> k2) -> SomeSing (k1 ~> k2)
toSing f :: Demote (k1 ~> k2)
f = Sing Any -> SomeSing (k1 ~> k2)
forall k (a :: k). Sing a -> SomeSing k
SomeSing Sing Any
forall (f :: k1 ~> k2). Sing f
slam
where
slam :: forall (f :: k1 ~> k2). Sing f
slam :: Sing f
slam = SingFunction1 f -> Sing f
forall k1 k (f :: k1 ~> k). SingFunction1 f -> Sing f
singFun1 @f SingFunction1 f
lam
where
lam :: forall (t :: k1). Sing t -> Sing (f @@ t)
lam :: Sing t -> Sing (f @@ t)
lam x :: Sing t
x = Demote k2
-> (forall (a :: k2). Sing a -> Sing (f @@ t)) -> Sing (f @@ t)
forall k r.
SingKind k =>
Demote k -> (forall (a :: k). Sing a -> r) -> r
withSomeSing (Demote (k1 ~> k2)
Demote k1 -> Demote k2
f (Sing t -> Demote k1
forall k (a :: k). SingKind k => Sing a -> Demote k
fromSing Sing t
x)) (\(r :: Sing res) -> Sing a -> Sing (f @@ t)
forall a b. a -> b
unsafeCoerce Sing a
r)
type SingFunction1 f = forall t. Sing t -> Sing (f @@ t)
singFun1 :: forall f. SingFunction1 f -> Sing f
singFun1 :: SingFunction1 f -> Sing f
singFun1 f :: SingFunction1 f
f = SingFunction1 f -> SLambda f
forall k1 k2 (f :: k1 ~> k2).
(forall (t :: k1). Sing t -> Sing (f @@ t)) -> SLambda f
SLambda SingFunction1 f
f
type SingFunction2 f = forall t. Sing t -> SingFunction1 (f @@ t)
singFun2 :: forall f. SingFunction2 f -> Sing f
singFun2 :: SingFunction2 f -> Sing f
singFun2 f :: SingFunction2 f
f = (forall (t :: k1). Sing t -> Sing (f @@ t)) -> SLambda f
forall k1 k2 (f :: k1 ~> k2).
(forall (t :: k1). Sing t -> Sing (f @@ t)) -> SLambda f
SLambda (\x :: Sing t
x -> SingFunction1 (Apply f t) -> Sing (Apply f t)
forall k1 k (f :: k1 ~> k). SingFunction1 f -> Sing f
singFun1 (Sing t -> SingFunction1 (Apply f t)
SingFunction2 f
f Sing t
x))
type SingFunction3 f = forall t. Sing t -> SingFunction2 (f @@ t)
singFun3 :: forall f. SingFunction3 f -> Sing f
singFun3 :: SingFunction3 f -> Sing f
singFun3 f :: SingFunction3 f
f = (forall (t :: k1). Sing t -> Sing (f @@ t)) -> SLambda f
forall k1 k2 (f :: k1 ~> k2).
(forall (t :: k1). Sing t -> Sing (f @@ t)) -> SLambda f
SLambda (\x :: Sing t
x -> SingFunction2 (Apply f t) -> Sing (Apply f t)
forall k1 k1 k (f :: k1 ~> (k1 ~> k)). SingFunction2 f -> Sing f
singFun2 (Sing t -> SingFunction2 (Apply f t)
SingFunction3 f
f Sing t
x))
type SingFunction4 f = forall t. Sing t -> SingFunction3 (f @@ t)
singFun4 :: forall f. SingFunction4 f -> Sing f
singFun4 :: SingFunction4 f -> Sing f
singFun4 f :: SingFunction4 f
f = (forall (t :: k1). Sing t -> Sing (f @@ t)) -> SLambda f
forall k1 k2 (f :: k1 ~> k2).
(forall (t :: k1). Sing t -> Sing (f @@ t)) -> SLambda f
SLambda (\x :: Sing t
x -> SingFunction3 (Apply f t) -> Sing (Apply f t)
forall k1 k1 k1 k (f :: k1 ~> (k1 ~> (k1 ~> k))).
SingFunction3 f -> Sing f
singFun3 (Sing t -> SingFunction3 (Apply f t)
SingFunction4 f
f Sing t
x))
type SingFunction5 f = forall t. Sing t -> SingFunction4 (f @@ t)
singFun5 :: forall f. SingFunction5 f -> Sing f
singFun5 :: SingFunction5 f -> Sing f
singFun5 f :: SingFunction5 f
f = (forall (t :: k1). Sing t -> Sing (f @@ t)) -> SLambda f
forall k1 k2 (f :: k1 ~> k2).
(forall (t :: k1). Sing t -> Sing (f @@ t)) -> SLambda f
SLambda (\x :: Sing t
x -> SingFunction4 (Apply f t) -> Sing (Apply f t)
forall k1 k1 k1 k1 k (f :: k1 ~> (k1 ~> (k1 ~> (k1 ~> k)))).
SingFunction4 f -> Sing f
singFun4 (Sing t -> SingFunction4 (Apply f t)
SingFunction5 f
f Sing t
x))
type SingFunction6 f = forall t. Sing t -> SingFunction5 (f @@ t)
singFun6 :: forall f. SingFunction6 f -> Sing f
singFun6 :: SingFunction6 f -> Sing f
singFun6 f :: SingFunction6 f
f = (forall (t :: k1). Sing t -> Sing (f @@ t)) -> SLambda f
forall k1 k2 (f :: k1 ~> k2).
(forall (t :: k1). Sing t -> Sing (f @@ t)) -> SLambda f
SLambda (\x :: Sing t
x -> SingFunction5 (Apply f t) -> Sing (Apply f t)
forall k1 k1 k1 k1 k1 k
(f :: k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> k))))).
SingFunction5 f -> Sing f
singFun5 (Sing t -> SingFunction5 (Apply f t)
SingFunction6 f
f Sing t
x))
type SingFunction7 f = forall t. Sing t -> SingFunction6 (f @@ t)
singFun7 :: forall f. SingFunction7 f -> Sing f
singFun7 :: SingFunction7 f -> Sing f
singFun7 f :: SingFunction7 f
f = (forall (t :: k1). Sing t -> Sing (f @@ t)) -> SLambda f
forall k1 k2 (f :: k1 ~> k2).
(forall (t :: k1). Sing t -> Sing (f @@ t)) -> SLambda f
SLambda (\x :: Sing t
x -> SingFunction6 (Apply f t) -> Sing (Apply f t)
forall k1 k1 k1 k1 k1 k1 k
(f :: k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> k)))))).
SingFunction6 f -> Sing f
singFun6 (Sing t -> SingFunction6 (Apply f t)
SingFunction7 f
f Sing t
x))
type SingFunction8 f = forall t. Sing t -> SingFunction7 (f @@ t)
singFun8 :: forall f. SingFunction8 f -> Sing f
singFun8 :: SingFunction8 f -> Sing f
singFun8 f :: SingFunction8 f
f = (forall (t :: k1). Sing t -> Sing (f @@ t)) -> SLambda f
forall k1 k2 (f :: k1 ~> k2).
(forall (t :: k1). Sing t -> Sing (f @@ t)) -> SLambda f
SLambda (\x :: Sing t
x -> SingFunction7 (Apply f t) -> Sing (Apply f t)
forall k1 k1 k1 k1 k1 k1 k1 k
(f :: k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> k))))))).
SingFunction7 f -> Sing f
singFun7 (Sing t -> SingFunction7 (Apply f t)
SingFunction8 f
f Sing t
x))
unSingFun1 :: forall f. Sing f -> SingFunction1 f
unSingFun1 :: Sing f -> SingFunction1 f
unSingFun1 sf :: Sing f
sf = SLambda f -> SingFunction1 f
forall k1 k2 (f :: k1 ~> k2).
SLambda f -> forall (t :: k1). Sing t -> Sing (f @@ t)
applySing SLambda f
Sing f
sf
unSingFun2 :: forall f. Sing f -> SingFunction2 f
unSingFun2 :: Sing f -> SingFunction2 f
unSingFun2 sf :: Sing f
sf x :: Sing t
x = Sing (Apply f t) -> SingFunction1 (Apply f t)
forall k1 k (f :: k1 ~> k). Sing f -> SingFunction1 f
unSingFun1 (Sing f
sf Sing f -> Sing t -> Sing (Apply f t)
forall k1 k2 (f :: k1 ~> k2) (t :: k1).
Sing f -> Sing t -> Sing (f @@ t)
@@ Sing t
x)
unSingFun3 :: forall f. Sing f -> SingFunction3 f
unSingFun3 :: Sing f -> SingFunction3 f
unSingFun3 sf :: Sing f
sf x :: Sing t
x = Sing (Apply f t) -> SingFunction2 (Apply f t)
forall k1 k1 k (f :: k1 ~> (k1 ~> k)). Sing f -> SingFunction2 f
unSingFun2 (Sing f
sf Sing f -> Sing t -> Sing (Apply f t)
forall k1 k2 (f :: k1 ~> k2) (t :: k1).
Sing f -> Sing t -> Sing (f @@ t)
@@ Sing t
x)
unSingFun4 :: forall f. Sing f -> SingFunction4 f
unSingFun4 :: Sing f -> SingFunction4 f
unSingFun4 sf :: Sing f
sf x :: Sing t
x = Sing (Apply f t) -> SingFunction3 (Apply f t)
forall k1 k1 k1 k (f :: k1 ~> (k1 ~> (k1 ~> k))).
Sing f -> SingFunction3 f
unSingFun3 (Sing f
sf Sing f -> Sing t -> Sing (Apply f t)
forall k1 k2 (f :: k1 ~> k2) (t :: k1).
Sing f -> Sing t -> Sing (f @@ t)
@@ Sing t
x)
unSingFun5 :: forall f. Sing f -> SingFunction5 f
unSingFun5 :: Sing f -> SingFunction5 f
unSingFun5 sf :: Sing f
sf x :: Sing t
x = Sing (Apply f t) -> SingFunction4 (Apply f t)
forall k1 k1 k1 k1 k (f :: k1 ~> (k1 ~> (k1 ~> (k1 ~> k)))).
Sing f -> SingFunction4 f
unSingFun4 (Sing f
sf Sing f -> Sing t -> Sing (Apply f t)
forall k1 k2 (f :: k1 ~> k2) (t :: k1).
Sing f -> Sing t -> Sing (f @@ t)
@@ Sing t
x)
unSingFun6 :: forall f. Sing f -> SingFunction6 f
unSingFun6 :: Sing f -> SingFunction6 f
unSingFun6 sf :: Sing f
sf x :: Sing t
x = Sing (Apply f t) -> SingFunction5 (Apply f t)
forall k1 k1 k1 k1 k1 k
(f :: k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> k))))).
Sing f -> SingFunction5 f
unSingFun5 (Sing f
sf Sing f -> Sing t -> Sing (Apply f t)
forall k1 k2 (f :: k1 ~> k2) (t :: k1).
Sing f -> Sing t -> Sing (f @@ t)
@@ Sing t
x)
unSingFun7 :: forall f. Sing f -> SingFunction7 f
unSingFun7 :: Sing f -> SingFunction7 f
unSingFun7 sf :: Sing f
sf x :: Sing t
x = Sing (Apply f t) -> SingFunction6 (Apply f t)
forall k1 k1 k1 k1 k1 k1 k
(f :: k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> k)))))).
Sing f -> SingFunction6 f
unSingFun6 (Sing f
sf Sing f -> Sing t -> Sing (Apply f t)
forall k1 k2 (f :: k1 ~> k2) (t :: k1).
Sing f -> Sing t -> Sing (f @@ t)
@@ Sing t
x)
unSingFun8 :: forall f. Sing f -> SingFunction8 f
unSingFun8 :: Sing f -> SingFunction8 f
unSingFun8 sf :: Sing f
sf x :: Sing t
x = Sing (Apply f t) -> SingFunction7 (Apply f t)
forall k1 k1 k1 k1 k1 k1 k1 k
(f :: k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> k))))))).
Sing f -> SingFunction7 f
unSingFun7 (Sing f
sf Sing f -> Sing t -> Sing (Apply f t)
forall k1 k2 (f :: k1 ~> k2) (t :: k1).
Sing f -> Sing t -> Sing (f @@ t)
@@ Sing t
x)
{-# COMPLETE SLambda2 #-}
pattern SLambda2 :: forall f. SingFunction2 f -> Sing f
pattern $bSLambda2 :: SingFunction2 f -> Sing f
$mSLambda2 :: forall r k1 k2 k (f :: k1 ~> (k2 ~> k)).
Sing f -> (SingFunction2 f -> r) -> (Void# -> r) -> r
SLambda2 {Sing f -> forall (t :: k1). Sing t -> SingFunction1 (f @@ t)
applySing2} <- (unSingFun2 -> applySing2)
where SLambda2 lam2 :: SingFunction2 f
lam2 = SingFunction2 f -> Sing f
forall k1 k1 k (f :: k1 ~> (k1 ~> k)). SingFunction2 f -> Sing f
singFun2 SingFunction2 f
lam2
{-# COMPLETE SLambda3 #-}
pattern SLambda3 :: forall f. SingFunction3 f -> Sing f
pattern $bSLambda3 :: SingFunction3 f -> Sing f
$mSLambda3 :: forall r k1 k2 k3 k (f :: k1 ~> (k2 ~> (k3 ~> k))).
Sing f -> (SingFunction3 f -> r) -> (Void# -> r) -> r
SLambda3 {Sing f -> forall (t :: k1). Sing t -> SingFunction2 (f @@ t)
applySing3} <- (unSingFun3 -> applySing3)
where SLambda3 lam3 :: SingFunction3 f
lam3 = SingFunction3 f -> Sing f
forall k1 k1 k1 k (f :: k1 ~> (k1 ~> (k1 ~> k))).
SingFunction3 f -> Sing f
singFun3 SingFunction3 f
lam3
{-# COMPLETE SLambda4 #-}
pattern SLambda4 :: forall f. SingFunction4 f -> Sing f
pattern $bSLambda4 :: SingFunction4 f -> Sing f
$mSLambda4 :: forall r k1 k2 k3 k4 k (f :: k1 ~> (k2 ~> (k3 ~> (k4 ~> k)))).
Sing f -> (SingFunction4 f -> r) -> (Void# -> r) -> r
SLambda4 {Sing f -> forall (t :: k1). Sing t -> SingFunction3 (f @@ t)
applySing4} <- (unSingFun4 -> applySing4)
where SLambda4 lam4 :: SingFunction4 f
lam4 = SingFunction4 f -> Sing f
forall k1 k1 k1 k1 k (f :: k1 ~> (k1 ~> (k1 ~> (k1 ~> k)))).
SingFunction4 f -> Sing f
singFun4 SingFunction4 f
lam4
{-# COMPLETE SLambda5 #-}
pattern SLambda5 :: forall f. SingFunction5 f -> Sing f
pattern $bSLambda5 :: SingFunction5 f -> Sing f
$mSLambda5 :: forall r k1 k2 k3 k4 k5 k
(f :: k1 ~> (k2 ~> (k3 ~> (k4 ~> (k5 ~> k))))).
Sing f -> (SingFunction5 f -> r) -> (Void# -> r) -> r
SLambda5 {Sing f -> forall (t :: k1). Sing t -> SingFunction4 (f @@ t)
applySing5} <- (unSingFun5 -> applySing5)
where SLambda5 lam5 :: SingFunction5 f
lam5 = SingFunction5 f -> Sing f
forall k1 k1 k1 k1 k1 k
(f :: k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> k))))).
SingFunction5 f -> Sing f
singFun5 SingFunction5 f
lam5
{-# COMPLETE SLambda6 #-}
pattern SLambda6 :: forall f. SingFunction6 f -> Sing f
pattern $bSLambda6 :: SingFunction6 f -> Sing f
$mSLambda6 :: forall r k1 k2 k3 k4 k5 k6 k
(f :: k1 ~> (k2 ~> (k3 ~> (k4 ~> (k5 ~> (k6 ~> k)))))).
Sing f -> (SingFunction6 f -> r) -> (Void# -> r) -> r
SLambda6 {Sing f -> forall (t :: k1). Sing t -> SingFunction5 (f @@ t)
applySing6} <- (unSingFun6 -> applySing6)
where SLambda6 lam6 :: SingFunction6 f
lam6 = SingFunction6 f -> Sing f
forall k1 k1 k1 k1 k1 k1 k
(f :: k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> k)))))).
SingFunction6 f -> Sing f
singFun6 SingFunction6 f
lam6
{-# COMPLETE SLambda7 #-}
pattern SLambda7 :: forall f. SingFunction7 f -> Sing f
pattern $bSLambda7 :: SingFunction7 f -> Sing f
$mSLambda7 :: forall r k1 k2 k3 k4 k5 k6 k7 k
(f :: k1 ~> (k2 ~> (k3 ~> (k4 ~> (k5 ~> (k6 ~> (k7 ~> k))))))).
Sing f -> (SingFunction7 f -> r) -> (Void# -> r) -> r
SLambda7 {Sing f -> forall (t :: k1). Sing t -> SingFunction6 (f @@ t)
applySing7} <- (unSingFun7 -> applySing7)
where SLambda7 lam7 :: SingFunction7 f
lam7 = SingFunction7 f -> Sing f
forall k1 k1 k1 k1 k1 k1 k1 k
(f :: k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> k))))))).
SingFunction7 f -> Sing f
singFun7 SingFunction7 f
lam7
{-# COMPLETE SLambda8 #-}
pattern SLambda8 :: forall f. SingFunction8 f -> Sing f
pattern $bSLambda8 :: SingFunction8 f -> Sing f
$mSLambda8 :: forall r k1 k2 k3 k4 k5 k6 k7 k8 k
(f :: k1
~> (k2 ~> (k3 ~> (k4 ~> (k5 ~> (k6 ~> (k7 ~> (k8 ~> k)))))))).
Sing f -> (SingFunction8 f -> r) -> (Void# -> r) -> r
SLambda8 {Sing f -> forall (t :: k1). Sing t -> SingFunction7 (f @@ t)
applySing8} <- (unSingFun8 -> applySing8)
where SLambda8 lam8 :: SingFunction8 f
lam8 = SingFunction8 f -> Sing f
forall k1 k1 k1 k1 k1 k1 k1 k1 k
(f :: k1
~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> (k1 ~> k)))))))).
SingFunction8 f -> Sing f
singFun8 SingFunction8 f
lam8
withSingI :: Sing n -> (SingI n => r) -> r
withSingI :: Sing n -> (SingI n => r) -> r
withSingI sn :: Sing n
sn r :: SingI n => r
r =
case Sing n -> SingInstance n
forall k (a :: k). Sing a -> SingInstance a
singInstance Sing n
sn of
SingInstance -> r
SingI n => r
r
withSomeSing :: forall k r
. SingKind k
=> Demote k
-> (forall (a :: k). Sing a -> r)
-> r
withSomeSing :: Demote k -> (forall (a :: k). Sing a -> r) -> r
withSomeSing x :: Demote k
x f :: forall (a :: k). Sing a -> r
f =
case Demote k -> SomeSing k
forall k. SingKind k => Demote k -> SomeSing k
toSing Demote k
x of
SomeSing x' :: Sing a
x' -> Sing a -> r
forall (a :: k). Sing a -> r
f Sing a
x'
withSing :: SingI a => (Sing a -> b) -> b
withSing :: (Sing a -> b) -> b
withSing f :: Sing a -> b
f = Sing a -> b
f Sing a
forall k (a :: k). SingI a => Sing a
sing
singThat :: forall k (a :: k). (SingKind k, SingI a)
=> (Demote k -> Bool) -> Maybe (Sing a)
singThat :: (Demote k -> Bool) -> Maybe (Sing a)
singThat p :: Demote k -> Bool
p = (Sing a -> Maybe (Sing a)) -> Maybe (Sing a)
forall k (a :: k) b. SingI a => (Sing a -> b) -> b
withSing ((Sing a -> Maybe (Sing a)) -> Maybe (Sing a))
-> (Sing a -> Maybe (Sing a)) -> Maybe (Sing a)
forall a b. (a -> b) -> a -> b
$ \x :: Sing a
x -> if Demote k -> Bool
p (Sing a -> Demote k
forall k (a :: k). SingKind k => Sing a -> Demote k
fromSing Sing a
x) then Sing a -> Maybe (Sing a)
forall a. a -> Maybe a
Just Sing a
x else Maybe (Sing a)
forall a. Maybe a
Nothing
singByProxy :: SingI a => proxy a -> Sing a
singByProxy :: proxy a -> Sing a
singByProxy _ = Sing a
forall k (a :: k). SingI a => Sing a
sing
singByProxy# :: SingI a => Proxy# a -> Sing a
singByProxy# :: Proxy# a -> Sing a
singByProxy# _ = Sing a
forall k (a :: k). SingI a => Sing a
sing
demote :: forall a. (SingKind (KindOf a), SingI a) => Demote (KindOf a)
demote :: Demote (KindOf a)
demote = Sing a -> Demote (KindOf a)
forall k (a :: k). SingKind k => Sing a -> Demote k
fromSing (SingI a => Sing a
forall k (a :: k). SingI a => Sing a
sing @a)