{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Data.Singletons.Prelude.Const (
Sing, SConst(..), GetConst, sGetConst,
ConstSym0, ConstSym1,
GetConstSym0, GetConstSym1
) where
import Control.Applicative
import Data.Kind (Type)
import Data.Singletons.Internal
import Data.Singletons.Prelude.Base
hiding ( Const, ConstSym0, ConstSym1
, Foldr, FoldrSym0, sFoldr )
import Data.Singletons.Prelude.Enum
import Data.Singletons.Prelude.Eq
import Data.Singletons.Prelude.Foldable
import Data.Singletons.Prelude.Instances hiding (FoldlSym0, sFoldl)
import Data.Singletons.Prelude.Monad.Internal
import Data.Singletons.Prelude.Monoid
import Data.Singletons.Prelude.Num
import Data.Singletons.Prelude.Ord
import Data.Singletons.Prelude.Semigroup.Internal
import Data.Singletons.Prelude.Show
import Data.Singletons.Promote
import Data.Singletons.Single
type SConst :: Const a b -> Type
data SConst c where
SConst :: Sing a -> SConst ('Const a)
type instance Sing = SConst
instance SingKind a => SingKind (Const a b) where
type Demote (Const a b) = Const (Demote a) b
fromSing :: Sing a -> Demote (Const a b)
fromSing (SConst sa) = Demote a -> Const (Demote a) b
forall k a (b :: k). a -> Const a b
Const (Sing a -> Demote a
forall k (a :: k). SingKind k => Sing a -> Demote k
fromSing Sing a
sa)
toSing :: Demote (Const a b) -> SomeSing (Const a b)
toSing (Const a) = Demote a
-> (forall (a :: a). Sing a -> SomeSing (Const a b))
-> SomeSing (Const a b)
forall k r.
SingKind k =>
Demote k -> (forall (a :: k). Sing a -> r) -> r
withSomeSing Demote a
a ((forall (a :: a). Sing a -> SomeSing (Const a b))
-> SomeSing (Const a b))
-> (forall (a :: a). Sing a -> SomeSing (Const a b))
-> SomeSing (Const a b)
forall a b. (a -> b) -> a -> b
$ SConst ('Const a) -> SomeSing (Const a b)
forall k (a :: k). Sing a -> SomeSing k
SomeSing (SConst ('Const a) -> SomeSing (Const a b))
-> (Sing a -> SConst ('Const a)) -> Sing a -> SomeSing (Const a b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sing a -> SConst ('Const a)
forall a k (b :: k) (a :: a). Sing a -> SConst ('Const a)
SConst
instance SingI a => SingI ('Const a) where
sing :: Sing ('Const a)
sing = Sing a -> SConst ('Const a)
forall a k (b :: k) (a :: a). Sing a -> SConst ('Const a)
SConst Sing a
forall k (a :: k). SingI a => Sing a
sing
$(genDefunSymbols [''Const])
instance SingI ConstSym0 where
sing :: Sing ConstSym0
sing = SingFunction1 ConstSym0 -> Sing ConstSym0
forall a1 b (f :: a1 ~> b). SingFunction1 f -> Sing f
singFun1 SingFunction1 ConstSym0
forall a k (b :: k) (a :: a). Sing a -> SConst ('Const a)
SConst
$(