{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeApplications #-}
module PlutusCore.Builtin.KnownKind where
import PlutusCore.Core
import Data.Kind as GHC
import GHC.Types
import Universe
data SingKind k where
SingType :: SingKind GHC.Type
SingKindArrow :: SingKind k -> SingKind l -> SingKind (k -> l)
class KnownKind k where
knownKind :: SingKind k
instance rep ~ LiftedRep => KnownKind (TYPE rep) where
knownKind :: SingKind (TYPE rep)
knownKind = SingKind (TYPE rep)
SingKind *
SingType
instance (KnownKind dom, KnownKind cod) => KnownKind (dom -> cod) where
knownKind :: SingKind (dom -> cod)
knownKind = SingKind dom -> SingKind cod -> SingKind (dom -> cod)
forall k l. SingKind k -> SingKind l -> SingKind (k -> l)
SingKindArrow (KnownKind dom => SingKind dom
forall k. KnownKind k => SingKind k
knownKind @dom) (KnownKind cod => SingKind cod
forall k. KnownKind k => SingKind k
knownKind @cod)
class ToKind (uni :: GHC.Type -> GHC.Type) where
toSingKind :: uni (Esc (a :: k)) -> SingKind k
demoteKind :: SingKind k -> Kind ()
demoteKind :: SingKind k -> Kind ()
demoteKind SingKind k
SingType = () -> Kind ()
forall ann. ann -> Kind ann
Type ()
demoteKind (SingKindArrow SingKind k
dom SingKind l
cod) = () -> Kind () -> Kind () -> Kind ()
forall ann. ann -> Kind ann -> Kind ann -> Kind ann
KindArrow () (SingKind k -> Kind ()
forall k. SingKind k -> Kind ()
demoteKind SingKind k
dom) (SingKind l -> Kind ()
forall k. SingKind k -> Kind ()
demoteKind SingKind l
cod)
kindOfBuiltinType :: ToKind uni => uni (Esc a) -> Kind ()
kindOfBuiltinType :: uni (Esc a) -> Kind ()
kindOfBuiltinType = SingKind k -> Kind ()
forall k. SingKind k -> Kind ()
demoteKind (SingKind k -> Kind ())
-> (uni (Esc a) -> SingKind k) -> uni (Esc a) -> Kind ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. uni (Esc a) -> SingKind k
forall (uni :: * -> *) k (a :: k).
ToKind uni =>
uni (Esc a) -> SingKind k
toSingKind