module DDC.Core.Llvm.Convert.Error
(Error (..))
where
import DDC.Core.Module
import DDC.Core.Exp
import DDC.Base.Pretty
import DDC.Core.Exp.Generic.Pretty ()
import Data.Maybe
import qualified DDC.Core.Salt as A
data Error
= ErrorInvalidBound
{ errorBound :: Bound A.Name
, errorDetails :: Maybe String }
| ErrorInvalidBind
{ errorBind :: Bind A.Name
, errorDetails :: Maybe String }
| ErrorInvalidType
{ errorType :: Type A.Name
, errorDetails :: Maybe String }
| ErrorInvalidTyCon
{ errorTyCon :: TyCon A.Name
, errorDetails :: Maybe String }
| ErrorInvalidExp
{ errorExp :: A.Exp
, errorDetails :: Maybe String }
| ErrorInvalidAlt
{ errorAlt :: [A.Alt]
, errorDetails :: Maybe String }
| ErrorInvalidSuper
{ errorBind :: Bind A.Name
, errorExp :: A.Exp }
| ErrorInvalidModule
{ errorModule :: Module () A.Name }
| ErrorInvalidSizeType
{ errorType :: Type A.Name }
| ErrorInvalidSize2Type
{ errorType :: Type A.Name }
| ErrorInvalidConversion
{ errorTypeFrom :: Type A.Name
, errorTypeTo :: Type A.Name }
| ErrorInvalidPromotion
{ errorTypeFrom :: Type A.Name
, errorTypeTo :: Type A.Name }
| ErrorInvalidTruncation
{ errorTypeFrom :: Type A.Name
, errorTypeTo :: Type A.Name }
| ErrorInvalidArith
{ errorPrimArith :: A.PrimArith
, errorType :: Type A.Name }
deriving Show
instance Pretty Error where
ppr (ErrorInvalidBound u md)
= vcat [ text "Invalid bound: " <> ppr u
, text $ fromMaybe "" md ]
ppr (ErrorInvalidBind b md)
= vcat [ text "Invalid bind: " <> ppr b
, text $ fromMaybe "" md ]
ppr (ErrorInvalidType t md)
= vcat [ text "Invalid type: " <> ppr t
, text $ fromMaybe "" md ]
ppr (ErrorInvalidTyCon tc md)
= vcat [ text "Invalid type constructor: " <> ppr tc
, text $ fromMaybe "" md ]
ppr (ErrorInvalidExp x md)
= vcat [ text "Invalid exp: " <> ppr x
, text $ fromMaybe "" md ]
ppr (ErrorInvalidAlt alts md)
= vcat [ text "Invalid alts: " <> ppr alts
, text $ fromMaybe "" md ]
ppr (ErrorInvalidSuper _n _x)
= vcat [ text "Invalid super." ]
ppr (ErrorInvalidModule _m)
= vcat [ text "Invalid module." ]
ppr (ErrorInvalidSizeType t)
= vcat [ text "Cannot apply size# to type '" <> ppr t <> text "'" ]
ppr (ErrorInvalidSize2Type t)
= vcat [ text "Cannot apply size2# to type '" <> ppr t <> text "'" ]
ppr (ErrorInvalidConversion tSrc tDst)
= vcat [ text "Cannot convert# value of type '" <> ppr tSrc
<> text "' to '" <> ppr tDst <> text "'" ]
ppr (ErrorInvalidPromotion tSrc tDst)
= vcat [ text "Cannot promote# value of type '" <> ppr tSrc
<> text "' to '" <> ppr tDst <> text "'" ]
ppr (ErrorInvalidTruncation tSrc tDst)
= vcat [ text "Cannot truncate# value of type '" <> ppr tSrc
<> text "' to '" <> ppr tDst <> text "'" ]
ppr (ErrorInvalidArith n t)
= vcat [ text "Cannot use " <> ppr n
<> text " at type '" <> ppr t <> text "'" ]