Mikan
Safe HaskellNone
LanguageHaskell2010

Mikan.TypeChecking.Monad.State

Description

Lenses for TCState and more.

Synopsis

Documentation

resetState :: TCM () Source #

Resets the non-persistent part of the type checking state.

resetAllState :: TCM () Source #

Resets all of the type checking state.

Keep only the session state (backend information, Benchmark, file ids).

putTCPreservingStats :: TCState -> TCM () Source #

Set the TCState, preserving any parts of the state which should persist through speculation (e.g., statistics).

localTCState :: TCM a -> TCM a Source #

Restore TCState after performing subcomputation.

Parts of the state which should not be reset on speculation (e.g., statistics) will not be reset.

localTCStateSaving :: TCM a -> TCM (a, TCState) Source #

Same as localTCState, but also returns the state in which we were just before reverting it.

localTCStateSavingWarnings :: TCM a -> TCM a Source #

Same as localTCState but keep all warnings.

freshTCM :: TCM a -> TCM (Either TCErr a) Source #

A fresh TCM instance.

The computation is run in a fresh state, with the exception that the persistent state is preserved. If the computation changes the state, then these changes are ignored, except for changes to the persistent state. (Changes to the persistent state are also ignored if errors other than type errors or IO exceptions are encountered.)

Lens for persistent states and its fields

Scope

getScope :: ReadTCState m => m ScopeInfo Source #

Get the current scope.

setScope :: ScopeInfo -> TCM () Source #

Set the current scope.

modifyScope :: MonadTCState m => (ScopeInfo -> ScopeInfo) -> m () Source #

Modify the current scope without updating the inverse maps.

recomputeInverseScope :: MonadTCState m => m () Source #

Recompute inverse names, inverse modules and InScopeSet-s.

useScope :: ReadTCState m => Lens' ScopeInfo a -> m a Source #

Get a part of the current scope.

locallyScope :: ReadTCState m => Lens' ScopeInfo a -> (a -> a) -> m b -> m b Source #

Run a computation in a modified scope.

withScope :: ReadTCState m => ScopeInfo -> m a -> m (a, ScopeInfo) Source #

Run a computation in a local scope.

evalWithScope :: ReadTCState m => ScopeInfo -> m a -> m a Source #

Same as withScope, but discard the scope from the computation.

localScope :: TCM a -> TCM a Source #

Discard any changes to the scope by a computation.

notInScopeError :: QName -> TCM a Source #

Scope error.

printScope :: String -> Int -> String -> TCM () Source #

Debug print the scope.

Signature

Lens for stSignature and stImports

withSignature :: (ReadTCState m, MonadTCState m) => Signature -> m a -> m a Source #

Run some computation in a different signature, restore original signature.

modify methods for the signature

Modifiers for parts of the signature

File identification

registerFileIdWithBuiltin :: File -> FileDictWithBuiltins -> (FileId, FileDictWithBuiltins) Source #

Translate an absolute path to a file id, and register a new file id if the path has not seen before. Also register whether the path belongs to one of Agda's builtin modules.

isBuiltinModule :: ReadTCState m => FileId -> m (Maybe IsBuiltinModule) Source #

Does the given FileId belong to one of Agda's builtin modules?

isBuiltinModuleWithSafePostulates :: ReadTCState m => FileId -> m Bool Source #

Does the given FileId belong to one of Agda's builtin modules that only uses safe postulates?

Implies isJust . isBuiltinModule.

isPrimitiveModule :: ReadTCState m => FileId -> m Bool Source #

Does the given FileId belong to one of Agda's magical primitive modules?

Implies isBuiltinModuleWithSafePostulates.

Top level module

topLevelModuleName :: RawTopLevelModuleName -> TCM TopLevelModuleName Source #

Tries to convert a raw top-level module name to a top-level module name.

setTopLevelModule :: TopLevelModuleName -> TCM () Source #

Set the top-level module. This affects the global module id of freshly generated names.

currentTopLevelModule :: (MonadTCEnv m, ReadTCState m) => m (Maybe TopLevelModuleName) Source #

The name of the current top-level module, if any.

withTopLevelModule :: TopLevelModuleName -> TCM a -> TCM a Source #

Use a different top-level module for a computation. Used when generating names for imported modules.

Backends and foreign code

lookupBackend :: ReadTCState m => BackendName -> m (Maybe Backend) Source #

Look for a backend of the given name.

activeBackend :: TCM (Maybe Backend) Source #

Get the currently active backend (if any).

activeBackendMayEraseType :: QName -> TCM Bool Source #

Ask the active backend whether a type may be erased. See issue #3732.

Interaction output callback

Pattern synonyms

getAllPatternSyns :: ReadTCState m => m PatternSynDefns Source #

Get both local and imported pattern synonyms

Instance definitions

clearUnknownInstance :: QName -> TCM () Source #

Remove an instance from the set of unresolved instances.

addUnknownInstance :: QName -> TCM () Source #

Add an instance whose type is still unresolved.

Orphan instances