我不认为这是可能的标准
TypeError
,但您可以定义自己的变体(
TE
{-# LANGUAGE
DataKinds, UndecidableInstances,
MultiParamTypeClasses, KindSignatures, TypeFamilies #-}
import GHC.TypeLits
import Data.Kind
class Impossible where
impossible :: a
type family TE (t :: ErrorMessage) :: Constraint where
TE t = (TypeError t, Impossible)
class C t where
foo :: t -> Bool
instance (TE (Text "impossible")) => C Bool where
foo _ = impossible