| Copyright | (c) 2013-2016 Galois Inc. |
|---|---|
| License | BSD3 |
| Maintainer | cryptol@galois.com |
| Stability | provisional |
| Portability | portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Cryptol.ModuleSystem.Renamer
Description
Synopsis
- data NamingEnv
- shadowing :: NamingEnv -> NamingEnv -> NamingEnv
- class BindsNames a
- data InModule a = InModule (Maybe ModPath) a
- shadowNames :: BindsNames env => env -> RenameM a -> RenameM a
- class Rename (f :: Type -> Type) where
- runRenamer :: RenamerInfo -> RenameM a -> (Either [RenamerError] (a, Supply), [RenamerWarning])
- data RenameM a
- data RenamerError
- = MultipleSyms (Located PName) [Name]
- | UnboundName Namespace (Located PName)
- | OverlappingSyms [Name]
- | WrongNamespace Namespace Namespace (Located PName)
- | FixityError (Located Name) Fixity (Located Name) Fixity
- | OverlappingRecordUpdate (Located [Selector]) (Located [Selector])
- | InvalidDependency [DepName]
- | MultipleModParams Ident [Range]
- | InvalidFunctorImport (ImpName Name)
- | UnexpectedNest Range PName
- | ModuleKindMismatch Range (ImpName Name) ModKind ModKind
- data RenamerWarning
- = SymbolShadowed PName Name [Name]
- | UnusedName Name
- | PrefixAssocChanged PrefixOp (Expr Name) (Located Name) Fixity (Expr Name)
- renameVar :: NameType -> PName -> RenameM Name
- renameType :: NameType -> PName -> RenameM Name
- renameModule :: Module PName -> RenameM RenamedModule
- renameTopDecls :: ModName -> [TopDecl PName] -> RenameM (NamingEnv, [TopDecl Name])
- data RenamerInfo = RenamerInfo {}
- data NameType
- data RenamedModule = RenamedModule {}
Documentation
The NamingEnv is used by the renamer to determine what
identifiers refer to.
Instances
shadowing :: NamingEnv -> NamingEnv -> NamingEnv Source #
Like mappend, but when merging, prefer values on the lhs.
class BindsNames a Source #
Things that define exported names.
Minimal complete definition
namingEnv
Instances
| BindsNames NamingEnv Source # | |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames (InModule (Bind PName)) Source # | Introduce the name |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames (InModule (Decl PName)) Source # | The naming environment for a single declaration. |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames (InModule (EnumDecl PName)) Source # | |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames (InModule (NestedModule PName)) Source # | |
Defined in Cryptol.ModuleSystem.Binds Methods namingEnv :: InModule (NestedModule PName) -> BuildNamingEnv | |
| BindsNames (InModule (Newtype PName)) Source # | |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames (InModule (ParameterFun PName)) Source # | |
Defined in Cryptol.ModuleSystem.Binds Methods namingEnv :: InModule (ParameterFun PName) -> BuildNamingEnv | |
| BindsNames (InModule (ParameterType PName)) Source # | |
Defined in Cryptol.ModuleSystem.Binds Methods namingEnv :: InModule (ParameterType PName) -> BuildNamingEnv | |
| BindsNames (InModule (PrimType PName)) Source # | |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames (InModule (SigDecl PName)) Source # | |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames (InModule (TopDecl PName)) Source # | |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames (Pattern PName) Source # | |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames (Schema PName) Source # | Generate a type renaming environment from the parameters that are bound by this schema. |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames (TParam PName) Source # | Generate the naming environment for a type parameter. |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames a => BindsNames (Maybe a) Source # | |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames a => BindsNames [a] Source # | |
Defined in Cryptol.ModuleSystem.Binds Methods namingEnv :: [a] -> BuildNamingEnv | |
Do something in the context of a module.
If Nothing than we are working with a local declaration.
Otherwise we are at the top-level of the given module.
By wrapping types with this, we can pass the module path to methods that need the extra information.
Instances
| Foldable InModule Source # | |
Defined in Cryptol.ModuleSystem.Binds Methods fold :: Monoid m => InModule m -> m # foldMap :: Monoid m => (a -> m) -> InModule a -> m # foldMap' :: Monoid m => (a -> m) -> InModule a -> m # foldr :: (a -> b -> b) -> b -> InModule a -> b # foldr' :: (a -> b -> b) -> b -> InModule a -> b # foldl :: (b -> a -> b) -> b -> InModule a -> b # foldl' :: (b -> a -> b) -> b -> InModule a -> b # foldr1 :: (a -> a -> a) -> InModule a -> a # foldl1 :: (a -> a -> a) -> InModule a -> a # elem :: Eq a => a -> InModule a -> Bool # maximum :: Ord a => InModule a -> a # minimum :: Ord a => InModule a -> a # | |
| Traversable InModule Source # | |
Defined in Cryptol.ModuleSystem.Binds | |
| Functor InModule Source # | |
| Show a => Show (InModule a) Source # | |
| BindsNames (InModule (Bind PName)) Source # | Introduce the name |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames (InModule (Decl PName)) Source # | The naming environment for a single declaration. |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames (InModule (EnumDecl PName)) Source # | |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames (InModule (NestedModule PName)) Source # | |
Defined in Cryptol.ModuleSystem.Binds Methods namingEnv :: InModule (NestedModule PName) -> BuildNamingEnv | |
| BindsNames (InModule (Newtype PName)) Source # | |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames (InModule (ParameterFun PName)) Source # | |
Defined in Cryptol.ModuleSystem.Binds Methods namingEnv :: InModule (ParameterFun PName) -> BuildNamingEnv | |
| BindsNames (InModule (ParameterType PName)) Source # | |
Defined in Cryptol.ModuleSystem.Binds Methods namingEnv :: InModule (ParameterType PName) -> BuildNamingEnv | |
| BindsNames (InModule (PrimType PName)) Source # | |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames (InModule (SigDecl PName)) Source # | |
Defined in Cryptol.ModuleSystem.Binds | |
| BindsNames (InModule (TopDecl PName)) Source # | |
Defined in Cryptol.ModuleSystem.Binds | |
shadowNames :: BindsNames env => env -> RenameM a -> RenameM a Source #
Shadow the current naming environment with some more names.
class Rename (f :: Type -> Type) where Source #
Instances
| Rename Bind Source # | Rename a binding. |
| Rename BindDef Source # | |
| Rename BindImpl Source # | |
| Rename CaseAlt Source # | |
| Rename Decl Source # | |
| Rename EnumDecl Source # | |
| Rename Expr Source # | |
| Rename FunDesc Source # | |
| Rename ImpName Source # | |
| Rename Match Source # | |
| Rename ModParam Source # | |
| Rename ModuleInstanceArg Source # | |
Defined in Cryptol.ModuleSystem.Renamer Methods rename :: ModuleInstanceArg PName -> RenameM (ModuleInstanceArg Name) Source # | |
| Rename ModuleInstanceArgs Source # | |
Defined in Cryptol.ModuleSystem.Renamer Methods rename :: ModuleInstanceArgs PName -> RenameM (ModuleInstanceArgs Name) Source # | |
| Rename ModuleInstanceNamedArg Source # | |
Defined in Cryptol.ModuleSystem.Renamer Methods rename :: ModuleInstanceNamedArg PName -> RenameM (ModuleInstanceNamedArg Name) Source # | |
| Rename NestedModule Source # | |
Defined in Cryptol.ModuleSystem.Renamer Methods rename :: NestedModule PName -> RenameM (NestedModule Name) Source # | |
| Rename Newtype Source # | |
| Rename ParameterFun Source # | |
Defined in Cryptol.ModuleSystem.Renamer Methods rename :: ParameterFun PName -> RenameM (ParameterFun Name) Source # | |
| Rename ParameterType Source # | |
Defined in Cryptol.ModuleSystem.Renamer Methods rename :: ParameterType PName -> RenameM (ParameterType Name) Source # | |
| Rename Pattern Source # | |
| Rename PrimType Source # | |
| Rename Prop Source # | |
| Rename PropGuardCase Source # | |
Defined in Cryptol.ModuleSystem.Renamer Methods rename :: PropGuardCase PName -> RenameM (PropGuardCase Name) Source # | |
| Rename PropSyn Source # | |
| Rename Schema Source # | Rename a schema, assuming that none of its type variables are already in scope. |
| Rename SigDecl Source # | |
| Rename TParam Source # | |
| Rename TopDecl Source # | |
| Rename TySyn Source # | |
| Rename Type Source # | |
| Rename TypeInst Source # | |
| Rename UpdField Source # | Note that after this point the |
runRenamer :: RenamerInfo -> RenameM a -> (Either [RenamerError] (a, Supply), [RenamerWarning]) Source #
Instances
| Applicative RenameM Source # | |
| Functor RenameM Source # | |
| Monad RenameM Source # | |
| FreshM RenameM Source # | |
Defined in Cryptol.ModuleSystem.Renamer.Monad | |
| ExceptionM RenameM () Source # | |
Defined in Cryptol.ModuleSystem.Renamer.Monad | |
| (Semigroup a, Monoid a) => Monoid (RenameM a) Source # | |
| Semigroup a => Semigroup (RenameM a) Source # | |
data RenamerError Source #
Constructors
| MultipleSyms (Located PName) [Name] | Multiple imported symbols contain this name |
| UnboundName Namespace (Located PName) | Some name not bound to any definition |
| OverlappingSyms [Name] | An environment has produced multiple overlapping symbols |
| WrongNamespace Namespace Namespace (Located PName) | expected, actual. When a name is missing from the expected namespace, but exists in another |
| FixityError (Located Name) Fixity (Located Name) Fixity | When the fixity of two operators conflict |
| OverlappingRecordUpdate (Located [Selector]) (Located [Selector]) | When record updates overlap (e.g., |
| InvalidDependency [DepName] | Things that can't depend on each other |
| MultipleModParams Ident [Range] | Module parameters with the same name |
| InvalidFunctorImport (ImpName Name) | Can't import functors directly |
| UnexpectedNest Range PName | Nested modules were not supposed to appear here |
| ModuleKindMismatch Range (ImpName Name) ModKind ModKind | Exepcted one kind (first one) but found the other (second one) |
Instances
| Generic RenamerError Source # | |||||
Defined in Cryptol.ModuleSystem.Renamer.Error Associated Types
| |||||
| Show RenamerError Source # | |||||
Defined in Cryptol.ModuleSystem.Renamer.Error Methods showsPrec :: Int -> RenamerError -> ShowS # show :: RenamerError -> String # showList :: [RenamerError] -> ShowS # | |||||
| PP RenamerError Source # | |||||
Defined in Cryptol.ModuleSystem.Renamer.Error Methods ppPrec :: Int -> RenamerError -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> RenamerError -> Doc Source # | |||||
| NFData RenamerError Source # | |||||
Defined in Cryptol.ModuleSystem.Renamer.Error Methods rnf :: RenamerError -> () # | |||||
| Eq RenamerError Source # | |||||
Defined in Cryptol.ModuleSystem.Renamer.Error | |||||
| Ord RenamerError Source # | |||||
Defined in Cryptol.ModuleSystem.Renamer.Error Methods compare :: RenamerError -> RenamerError -> Ordering # (<) :: RenamerError -> RenamerError -> Bool # (<=) :: RenamerError -> RenamerError -> Bool # (>) :: RenamerError -> RenamerError -> Bool # (>=) :: RenamerError -> RenamerError -> Bool # max :: RenamerError -> RenamerError -> RenamerError # min :: RenamerError -> RenamerError -> RenamerError # | |||||
| type Rep RenamerError Source # | |||||
Defined in Cryptol.ModuleSystem.Renamer.Error type Rep RenamerError = D1 ('MetaData "RenamerError" "Cryptol.ModuleSystem.Renamer.Error" "cryptol-3.5.0-HoSGjqdyafy4TMoEJgOBMg" 'False) (((C1 ('MetaCons "MultipleSyms" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Located PName)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Name])) :+: C1 ('MetaCons "UnboundName" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Namespace) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Located PName)))) :+: (C1 ('MetaCons "OverlappingSyms" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Name])) :+: (C1 ('MetaCons "WrongNamespace" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Namespace) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Namespace) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Located PName)))) :+: C1 ('MetaCons "FixityError" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Located Name)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Fixity)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Located Name)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Fixity)))))) :+: ((C1 ('MetaCons "OverlappingRecordUpdate" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Located [Selector])) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Located [Selector]))) :+: (C1 ('MetaCons "InvalidDependency" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [DepName])) :+: C1 ('MetaCons "MultipleModParams" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Ident) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Range])))) :+: (C1 ('MetaCons "InvalidFunctorImport" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ImpName Name))) :+: (C1 ('MetaCons "UnexpectedNest" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Range) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PName)) :+: C1 ('MetaCons "ModuleKindMismatch" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Range) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ImpName Name))) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModKind) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModKind))))))) | |||||
data RenamerWarning Source #
Constructors
| SymbolShadowed PName Name [Name] | |
| UnusedName Name | |
| PrefixAssocChanged PrefixOp (Expr Name) (Located Name) Fixity (Expr Name) |
Instances
| Generic RenamerWarning Source # | |||||
Defined in Cryptol.ModuleSystem.Renamer.Error Associated Types
Methods from :: RenamerWarning -> Rep RenamerWarning x # to :: Rep RenamerWarning x -> RenamerWarning # | |||||
| Show RenamerWarning Source # | |||||
Defined in Cryptol.ModuleSystem.Renamer.Error Methods showsPrec :: Int -> RenamerWarning -> ShowS # show :: RenamerWarning -> String # showList :: [RenamerWarning] -> ShowS # | |||||
| PP RenamerWarning Source # | |||||
Defined in Cryptol.ModuleSystem.Renamer.Error Methods ppPrec :: Int -> RenamerWarning -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> RenamerWarning -> Doc Source # | |||||
| NFData RenamerWarning Source # | |||||
Defined in Cryptol.ModuleSystem.Renamer.Error Methods rnf :: RenamerWarning -> () # | |||||
| Eq RenamerWarning Source # | |||||
Defined in Cryptol.ModuleSystem.Renamer.Error Methods (==) :: RenamerWarning -> RenamerWarning -> Bool # (/=) :: RenamerWarning -> RenamerWarning -> Bool # | |||||
| Ord RenamerWarning Source # | |||||
Defined in Cryptol.ModuleSystem.Renamer.Error Methods compare :: RenamerWarning -> RenamerWarning -> Ordering # (<) :: RenamerWarning -> RenamerWarning -> Bool # (<=) :: RenamerWarning -> RenamerWarning -> Bool # (>) :: RenamerWarning -> RenamerWarning -> Bool # (>=) :: RenamerWarning -> RenamerWarning -> Bool # max :: RenamerWarning -> RenamerWarning -> RenamerWarning # min :: RenamerWarning -> RenamerWarning -> RenamerWarning # | |||||
| type Rep RenamerWarning Source # | |||||
Defined in Cryptol.ModuleSystem.Renamer.Error type Rep RenamerWarning = D1 ('MetaData "RenamerWarning" "Cryptol.ModuleSystem.Renamer.Error" "cryptol-3.5.0-HoSGjqdyafy4TMoEJgOBMg" 'False) (C1 ('MetaCons "SymbolShadowed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PName) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Name]))) :+: (C1 ('MetaCons "UnusedName" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name)) :+: C1 ('MetaCons "PrefixAssocChanged" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PrefixOp) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Expr Name))) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Located Name)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Fixity) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Expr Name))))))) | |||||
renameModule :: Module PName -> RenameM RenamedModule Source #
Entry point. This is used for renaming a top-level module.
renameTopDecls :: ModName -> [TopDecl PName] -> RenameM (NamingEnv, [TopDecl Name]) Source #
Entry point. Rename a list of top-level declarations. This is used for declaration that don't live in a module (e.g., define on the command line.)
We assume that these declarations do not contain any nested modules.
Indicates if a name is in a binding poisition or a use site
data RenamedModule Source #
The result of renaming a module
Constructors
| RenamedModule | |
Fields
| |
Instances
| PP RenamedModule Source # | |
Defined in Cryptol.ModuleSystem.Renamer Methods ppPrec :: Int -> RenamedModule -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> RenamedModule -> Doc Source # | |