{-# OPTIONS_HADDOCK hide, prune #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ExplicitNamespaces #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableSuperClasses #-}
module Data.Type.List.Internal
( UnreachableConstraint (..)
, type (=->) (..), runMagic, unsafeEqTypes
) where
import Data.Constraint (Dict (..))
import Data.Constraint.Bare
import Data.Kind
import Data.Proxy
import GHC.TypeLits
import Unsafe.Coerce (unsafeCoerce)
class UnreachableConstraint (ctx :: Constraint) (msg :: Symbol) where
unreachable :: BareConstraint ctx
instance KnownSymbol msg
=> UnreachableConstraint ctx msg where
unreachable = error $ "Unreachable constraint:: " ++ symbolVal (Proxy @msg)
newtype c =-> r = Magic (c => r)
infixr 0 =->
runMagic :: (c =-> r) -> BareConstraint c -> r
runMagic = unsafeCoerce
{-# NOINLINE runMagic #-}
unsafeEqTypes :: forall a b
. Dict (a ~ b)
unsafeEqTypes = unsafeCoerce (Dict :: Dict (a ~ a))