Mikan
Safe HaskellNone
LanguageHaskell2010

Mikan.TypeChecking.Monad.Diagnostic

Synopsis

The Diagnostic class

data DiagnosticReason Source #

The reason for raising a diagnostic.

Constructors

DiagError

The diagnostic is always an error.

DiagWarning

The diagnostic is a warning with the given name.

This DiagnosticReason should also be used for the "error warnings" which are controlled by an unsafe pragma option (like TerminationError, which can be turned off by --no-termination-check) even if the diagnostic can not be turned off by a -W flag.

Instances

Instances details
EmbPrj DiagnosticReason Source # 
Instance details

Defined in Mikan.TypeChecking.Serialise.Instances.Errors

NFData DiagnosticReason Source # 
Instance details

Defined in Mikan.TypeChecking.Monad.Diagnostic

Methods

rnf :: DiagnosticReason -> () #

Generic DiagnosticReason Source # 
Instance details

Defined in Mikan.TypeChecking.Monad.Diagnostic

Associated Types

type Rep DiagnosticReason 
Instance details

Defined in Mikan.TypeChecking.Monad.Diagnostic

type Rep DiagnosticReason = D1 ('MetaData "DiagnosticReason" "Mikan.TypeChecking.Monad.Diagnostic" "Mikan-2.9.0-CZbYRMbHmng2A9zjJ31VFu" 'False) (C1 ('MetaCons "DiagError" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DiagWarning" 'PrefixI 'True) (S1 ('MetaSel ('Just "_warningName") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 WarningName)))
Show DiagnosticReason Source # 
Instance details

Defined in Mikan.TypeChecking.Monad.Diagnostic

type Rep DiagnosticReason Source # 
Instance details

Defined in Mikan.TypeChecking.Monad.Diagnostic

type Rep DiagnosticReason = D1 ('MetaData "DiagnosticReason" "Mikan.TypeChecking.Monad.Diagnostic" "Mikan-2.9.0-CZbYRMbHmng2A9zjJ31VFu" 'False) (C1 ('MetaCons "DiagError" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DiagWarning" 'PrefixI 'True) (S1 ('MetaSel ('Just "_warningName") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 WarningName)))

class (NFData a, Show a, PrettyTCM a, Typeable a) => Diagnostic a where Source #

A Diagnostic is a value that can be thrown to abort elaboration (see typeError and variants), or logged to the set of warnings (see warning and variants).

New instances of Diagnostic (new type errors, new warnings) should be added in a support module adjacent to the component that raises them. For example, errors related to execution of metaprograms (implemented in Mikan.TypeChecking.Unquote) are defined in the module Mikan.TypeChecking.Unquote.Errors.

Minimal complete definition

diagnosticReason, diagnosticString

Methods

diagnosticReason :: a -> DiagnosticReason Source #

The reason, or "intrinsic severity", of a diagnostic.

This is the base for computing the actual severity of the diagnostic after flags are applied.

diagnosticString :: a -> String Source #

Return a string that identifies the diagnostic. It is generally, but not necessarily, the name of the constructor for that value as a string. These strings are shown to the user in brackets after the diagnostic's severity.

TODO: This should be replaced with something that statically guarantees a unique numeric identifier for each diagnostic constructor.

toSomeDiagnostic :: a -> SomeDiagnostic Source #

Wrap the Diagnostic into a SomeDiagnostic.

NOTE: This method should not be implemented manually. It only exists to avoid repeated boxing of SomeDiagnostics.

fromSomeDiagnostic :: SomeDiagnostic -> Maybe a Source #

Attempt to recover the Diagnostic from a SomeDiagnostic.

NOTE: This method should not be implemented manually. It only exists to avoid repeated boxing of SomeDiagnostics.

Instances

Instances details
Diagnostic InteractionError Source # 
Instance details

Defined in Mikan.Interaction.Errors

Diagnostic DeclarationException' Source # 
Instance details

Defined in Mikan.TypeChecking.Monad.Diagnostic

Diagnostic DeclarationWarning Source # 
Instance details

Defined in Mikan.TypeChecking.Warnings

Diagnostic IgnoredRecordDeclaration Source # 
Instance details

Defined in Mikan.Syntax.Scope.Errors

Diagnostic PatternSynonymError Source # 
Instance details

Defined in Mikan.Syntax.Scope.Errors

Diagnostic NoConstraintsError Source # 
Instance details

Defined in Mikan.TypeChecking.Constraints

Diagnostic ConversionError Source # 
Instance details

Defined in Mikan.TypeChecking.Conversion.Errors

Diagnostic SplitError Source # 
Instance details

Defined in Mikan.TypeChecking.Coverage.Errors

Diagnostic DeferredError Source # 
Instance details

Defined in Mikan.TypeChecking.Errors.Deferred

Diagnostic InstanceSearchError Source # 
Instance details

Defined in Mikan.TypeChecking.InstanceArguments.Errors

Diagnostic TypeError Source # 
Instance details

Defined in Mikan.TypeChecking.Monad.Diagnostic

Diagnostic UnsolvedWarning Source # 
Instance details

Defined in Mikan.TypeChecking.Warnings

Diagnostic Warning Source # 
Instance details

Defined in Mikan.TypeChecking.Warnings

Diagnostic EncodedDiagnostic Source # 
Instance details

Defined in Mikan.TypeChecking.Monad.Diagnostic

Diagnostic SomeDiagnostic Source # 
Instance details

Defined in Mikan.TypeChecking.Monad.Diagnostic

Diagnostic UnboundParameters Source # 
Instance details

Defined in Mikan.TypeChecking.Rules.Data

Diagnostic ExecError Source # 
Instance details

Defined in Mikan.TypeChecking.Unquote.Errors

Diagnostic UnquoteError Source # 
Instance details

Defined in Mikan.TypeChecking.Unquote.Errors

Wrappers for ferrying diagnostic values

The TCM needs to store Diagnostic values in two forms: for control flow, in TCErr; and for warning reporting, in TCWarning. TCErrs only exist during execution, and are sometimes matched on, while non-fatal TCWarnings can persist into interface files. These two needs are served by the wrapper types SomeDiagnostic and EncodedDiagnostic respectively.

data SomeDiagnostic Source #

A package precisely wrapping a Diagnostic value.

The Diagnostic methods toSomeDiagnostic and fromSomeDiagnostic can be used to up- and down-cast between SomeDiagnostic and a concrete Diagnostic type.

data EncodedDiagnostic Source #

The serialised form of a Diagnostic, recording only the identifying string and the intrinsic DiagnosticReason.

Can not be downcast back to the Diagnostic it was originally encoded from.

Instances

Instances details
Diagnostic EncodedDiagnostic Source # 
Instance details

Defined in Mikan.TypeChecking.Monad.Diagnostic

PrettyTCM EncodedDiagnostic Source # 
Instance details

Defined in Mikan.TypeChecking.Monad.Diagnostic

EmbPrj EncodedDiagnostic Source # 
Instance details

Defined in Mikan.TypeChecking.Serialise.Instances.Errors

NFData EncodedDiagnostic Source # 
Instance details

Defined in Mikan.TypeChecking.Monad.Diagnostic

Methods

rnf :: EncodedDiagnostic -> () #

Generic EncodedDiagnostic Source # 
Instance details

Defined in Mikan.TypeChecking.Monad.Diagnostic

Associated Types

type Rep EncodedDiagnostic 
Instance details

Defined in Mikan.TypeChecking.Monad.Diagnostic

type Rep EncodedDiagnostic = D1 ('MetaData "EncodedDiagnostic" "Mikan.TypeChecking.Monad.Diagnostic" "Mikan-2.9.0-CZbYRMbHmng2A9zjJ31VFu" 'False) (C1 ('MetaCons "EncodedDiagnostic" 'PrefixI 'True) (S1 ('MetaSel ('Just "_edReason") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DiagnosticReason) :*: S1 ('MetaSel ('Just "_edString") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String)))
Show EncodedDiagnostic Source # 
Instance details

Defined in Mikan.TypeChecking.Monad.Diagnostic

type Rep EncodedDiagnostic Source # 
Instance details

Defined in Mikan.TypeChecking.Monad.Diagnostic

type Rep EncodedDiagnostic = D1 ('MetaData "EncodedDiagnostic" "Mikan.TypeChecking.Monad.Diagnostic" "Mikan-2.9.0-CZbYRMbHmng2A9zjJ31VFu" 'False) (C1 ('MetaCons "EncodedDiagnostic" 'PrefixI 'True) (S1 ('MetaSel ('Just "_edReason") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DiagnosticReason) :*: S1 ('MetaSel ('Just "_edString") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String)))

internalErrorDiagnostic :: String -> SomeDiagnostic Source #

The SomeDiagnostic associated to an internal error.

NOTE: This is needed to break an import cycle: Mikan.Interaction.Monad.Base needs a SomeDiagnostic which can be thrown for the MonadError TCErr instance for TCM, but it can not import the Diagnostic class since that depends on PrettyTCM.

Monads which can throw and catch diagnostics

type MonadTCError (m :: Type -> Type) = (MonadTCEnv m, ReadTCState m, MonadError TCErr m) Source #

The constraints needed for typeError and similar.

typeError :: (HasCallStack, MonadTCError m, Diagnostic e) => e -> m a Source #

Throw a Diagnostic in a MonadTCError, associating the error with the source position from HasCallStack.

typeError' :: (MonadTCError m, Diagnostic e) => CallStack -> e -> m a Source #

Throw a Diagnostic in a MonadTCError with an explicit CallStack.

locatedTypeError :: (MonadTCError m, Diagnostic e) => (a -> e) -> HasCallStack => a -> m b Source #

Utility function for 1-arg constructed Diagnostics. Note that the HasCallStack constraint is on the *resulting* function.

typeError_ :: (HasCallStack, MonadTCEnv m, ReadTCState m, Diagnostic e) => e -> m TCErr Source #

Construct a TCErr value wrapping the given Diagnostic, associating it with the source position from HasCallStack.

typeError'_ :: (MonadTCEnv m, ReadTCState m, Diagnostic e) => CallStack -> e -> m TCErr Source #

Construct a TCErr value wrapping the given Diagnostic, associating it with the explicit CallStack.

internalError :: (HasCallStack, MonadTCError m) => String -> m a Source #

Raise an internal error (used for the MonadFail TCM instance).

Orphan instances