cryptol-2.4.0: Cryptol: The Language of Cryptography

Copyright | (c) 2013-2016 Galois Inc.
License | BSD3
Maintainer | cryptol@galois.com
Stability | provisional
Portability | portable
Safe Haskell | Safe
Language | Haskell98

Cryptol.ModuleSystem.Renamer

Description

Synopsis

- data NamingEnv
- shadowing :: NamingEnv -> NamingEnv -> NamingEnv
- class BindsNames a where
- data InModule a = InModule !ModName a
- namingEnv' :: BindsNames a => a -> Supply -> (NamingEnv, Supply)
- checkNamingEnv :: NamingEnv -> ([RenamerError], [RenamerWarning])
- shadowNames :: BindsNames env => env -> RenameM a -> RenameM a
- class Rename f where
- runRenamer :: Supply -> ModName -> NamingEnv -> RenameM a -> (Either [RenamerError] (a, Supply), [RenamerWarning])
- data RenameM a
- data RenamerError
  - = MultipleSyms (Located PName) [Name] NameDisp
  - | UnboundExpr (Located PName) NameDisp
  - | UnboundType (Located PName) NameDisp
  - | OverlappingSyms [Name] NameDisp
  - | ExpectedValue (Located PName) NameDisp
  - | ExpectedType (Located PName) NameDisp
  - | FixityError (Located Name) (Located Name) NameDisp
  - | InvalidConstraint (Type PName) NameDisp
  - | MalformedBuiltin (Type PName) PName NameDisp
  - | BoundReservedType PName (Maybe Range) Doc NameDisp
- data RenamerWarning = SymbolShadowed Name [Name] NameDisp
- renameVar :: PName -> RenameM Name
- renameType :: PName -> RenameM Name
- renameModule :: Module PName -> RenameM (NamingEnv, Module Name)

# Documentation

data NamingEnv Source #

Instances

Show NamingEnv Source # |
Methods showsPrec :: Int -> NamingEnv -> ShowS # show :: NamingEnv -> String # showList :: [NamingEnv] -> ShowS #
Generic NamingEnv Source # |
Associated Types type Rep NamingEnv :: * -> * # Methods from :: NamingEnv -> Rep NamingEnv x # to :: Rep NamingEnv x -> NamingEnv #
Monoid NamingEnv Source # |
Methods mempty :: NamingEnv # mappend :: NamingEnv -> NamingEnv -> NamingEnv # mconcat :: [NamingEnv] -> NamingEnv #
NFData NamingEnv Source # |
Methods rnf :: NamingEnv -> () #
BindsNames NamingEnv Source # |
Methods namingEnv :: NamingEnv -> BuildNamingEnv Source #
type Rep NamingEnv Source # |

type Rep NamingEnv = D1 (MetaData "NamingEnv" "Cryptol.ModuleSystem.NamingEnv" "cryptol-2.4.0-CN28BMG3PUFD1lr9WvB1U9" False) (C1 (MetaCons "NamingEnv" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "neExprs") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Map PName [Name]))) ((:*:) (S1 (MetaSel (Just Symbol "neTypes") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Map PName [Name]))) (S1 (MetaSel (Just Symbol "neFixity") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Map Name Fixity))))))

shadowing :: NamingEnv -> NamingEnv -> NamingEnv Source #

Like mappend, but when merging, prefer values on the lhs.

class BindsNames a where Source #

Things that define exported names.

Minimal complete definition

namingEnv

Methods

namingEnv :: a -> BuildNamingEnv Source #

Instances

BindsNames ImportIface Source # | Produce a naming environment from an interface file, that contains a mapping only from unqualified names to qualified ones.
Methods namingEnv :: ImportIface -> BuildNamingEnv Source #
BindsNames NamingEnv Source # |
Methods namingEnv :: NamingEnv -> BuildNamingEnv Source #
BindsNames a => BindsNames [a] Source # |
Methods namingEnv :: [a] -> BuildNamingEnv Source #
BindsNames a => BindsNames (Maybe a) Source # |
Methods namingEnv :: Maybe a -> BuildNamingEnv Source #
BindsNames (TParam PName) Source # | Generate the naming environment for a type parameter.
Methods namingEnv :: TParam PName -> BuildNamingEnv Source #
BindsNames (Schema PName) Source # | Generate a type renaming environment from the parameters that are bound by this schema.
Methods namingEnv :: Schema PName -> BuildNamingEnv Source #
BindsNames (Module PName) Source # | The naming environment for a single module. This is the mapping from unqualified names to fully qualified names with uniques.
Methods namingEnv :: Module PName -> BuildNamingEnv Source #
BindsNames (InModule (Newtype PName)) Source # |
Methods namingEnv :: InModule (Newtype PName) -> BuildNamingEnv Source #
BindsNames (InModule (Bind PName)) Source # | Introduce the name
Methods namingEnv :: InModule (Bind PName) -> BuildNamingEnv Source #
BindsNames (InModule (Decl PName)) Source # | The naming environment for a single declaration.
Methods namingEnv :: InModule (Decl PName) -> BuildNamingEnv Source #
BindsNames (InModule (TopDecl PName)) Source # |
Methods namingEnv :: InModule (TopDecl PName) -> BuildNamingEnv Source #

data InModule a Source #

Constructors

InModule !ModName a |

Instances

Functor InModule Source # |
Methods fmap :: (a -> b) -> InModule a -> InModule b # (<$) :: a -> InModule b -> InModule a #
Foldable InModule Source # |

Methods

fold :: Monoid m => InModule m -> 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 #

toList :: InModule a -> [a] #

null :: InModule a -> Bool #

length :: InModule a -> Int #

elem :: Eq a => a -> InModule a -> Bool #

maximum :: Ord a => InModule a -> a #

minimum :: Ord a => InModule a -> a #

sum :: Num a => InModule a -> a #

product :: Num a => InModule a -> a #

Traversable InModule Source # |
Methods traverse :: Applicative f => (a -> f b) -> InModule a -> f (InModule b) # sequenceA :: Applicative f => InModule (f a) -> f (InModule a) # mapM :: Monad m => (a -> m b) -> InModule a -> m (InModule b) # sequence :: Monad m => InModule (m a) -> m (InModule a) #
Show a => Show (InModule a) Source # |
Methods showsPrec :: Int -> InModule a -> ShowS # show :: InModule a -> String # showList :: [InModule a] -> ShowS #
BindsNames (InModule (Newtype PName)) Source # |
Methods namingEnv :: InModule (Newtype PName) -> BuildNamingEnv Source #
BindsNames (InModule (Bind PName)) Source # | Introduce the name
Methods namingEnv :: InModule (Bind PName) -> BuildNamingEnv Source #
BindsNames (InModule (Decl PName)) Source # | The naming environment for a single declaration.
Methods namingEnv :: InModule (Decl PName) -> BuildNamingEnv Source #
BindsNames (InModule (TopDecl PName)) Source # |
Methods namingEnv :: InModule (TopDecl PName) -> BuildNamingEnv Source #

namingEnv' :: BindsNames a => a -> Supply -> (NamingEnv, Supply) Source #

Generate a `NamingEnv` using an explicit supply.

checkNamingEnv :: NamingEnv -> ([RenamerError], [RenamerWarning]) Source #

Throw errors for any names that overlap in a rewrite environment.

shadowNames :: BindsNames env => env -> RenameM a -> RenameM a Source #

Shadow the current naming environment with some more names.

class Rename f where Source #

Minimal complete definition

rename

Methods

rename :: f PName -> RenameM (f Name) Source #

Instances

Rename Prop Source # |
Methods rename :: Prop PName -> RenameM (Prop Name) Source #
Rename Type Source # | Resolve fixity, then rename the resulting type.
Methods rename :: Type PName -> RenameM (Type Name) Source #
Rename TParam Source # |
Methods rename :: TParam PName -> RenameM (TParam Name) Source #
Rename Schema Source # | Rename a schema, assuming that none of its type variables are already in scope.
Methods rename :: Schema PName -> RenameM (Schema Name) Source #
Rename Pattern Source # |
Methods rename :: Pattern PName -> RenameM (Pattern Name) Source #
Rename Match Source # |
Methods rename :: Match PName -> RenameM (Match Name) Source #
Rename TypeInst Source # |
Methods rename :: TypeInst PName -> RenameM (TypeInst Name) Source #
Rename Expr Source # |
Methods rename :: Expr PName -> RenameM (Expr Name) Source #
Rename Newtype Source # |
Methods rename :: Newtype PName -> RenameM (Newtype Name) Source #
Rename BindDef Source # |
Methods rename :: BindDef PName -> RenameM (BindDef Name) Source #
Rename Bind Source # | Rename a binding.
Methods rename :: Bind PName -> RenameM (Bind Name) Source #
Rename TySyn Source # |
Methods rename :: TySyn PName -> RenameM (TySyn Name) Source #
Rename Decl Source # |
Methods rename :: Decl PName -> RenameM (Decl Name) Source #
Rename TopDecl Source # |
Methods rename :: TopDecl PName -> RenameM (TopDecl Name) Source #

runRenamer :: Supply -> ModName -> NamingEnv -> RenameM a -> (Either [RenamerError] (a, Supply), [RenamerWarning]) Source #

data RenameM a Source #

Instances

Monad RenameM Source # |
Methods (>>=) :: RenameM a -> (a -> RenameM b) -> RenameM b # (>>) :: RenameM a -> RenameM b -> RenameM b # return :: a -> RenameM a # fail :: String -> RenameM a #
Functor RenameM Source # |
Methods fmap :: (a -> b) -> RenameM a -> RenameM b # (<$) :: a -> RenameM b -> RenameM a #
Applicative RenameM Source # |
Methods pure :: a -> RenameM a # (<*>) :: RenameM (a -> b) -> RenameM a -> RenameM b # (*>) :: RenameM a -> RenameM b -> RenameM b # (<*) :: RenameM a -> RenameM b -> RenameM a #
FreshM RenameM Source # |
Methods liftSupply :: (Supply -> (a, Supply)) -> RenameM a Source #
Monoid a => Monoid (RenameM a) Source # |
Methods mempty :: RenameM a # mappend :: RenameM a -> RenameM a -> RenameM a # mconcat :: [RenameM a] -> RenameM a #

data RenamerError Source #

Constructors

MultipleSyms (Located PName) [Name] NameDisp | Multiple imported symbols contain this name
UnboundExpr (Located PName) NameDisp | Expression name is not bound to any definition
UnboundType (Located PName) NameDisp | Type name is not bound to any definition
OverlappingSyms [Name] NameDisp | An environment has produced multiple overlapping symbols
ExpectedValue (Located PName) NameDisp | When a value is expected from the naming environment, but one or more types exist instead.
ExpectedType (Located PName) NameDisp | When a type is missing from the naming environment, but one or more values exist with the same name.
FixityError (Located Name) (Located Name) NameDisp | When the fixity of two operators conflict
InvalidConstraint (Type PName) NameDisp | When it's not possible to produce a Prop from a Type.
MalformedBuiltin (Type PName) PName NameDisp | When a builtin type/type-function is used incorrectly.
BoundReservedType PName (Maybe Range) Doc NameDisp | When a builtin type is named in a binder.

Instances

Show RenamerError Source # |
Methods showsPrec :: Int -> RenamerError -> ShowS # show :: RenamerError -> String # showList :: [RenamerError] -> ShowS #
Generic RenamerError Source # |
Associated Types type Rep RenamerError :: * -> * # Methods from :: RenamerError -> Rep RenamerError x # to :: Rep RenamerError x -> RenamerError #
NFData RenamerError Source # |
Methods rnf :: RenamerError -> () #
PP RenamerError Source # |
Methods ppPrec :: Int -> RenamerError -> Doc Source #
type Rep RenamerError Source # |

type Rep RenamerError = D1 (MetaData "RenamerError" "Cryptol.ModuleSystem.Renamer" "cryptol-2.4.0-CN28BMG3PUFD1lr9WvB1U9" False) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "MultipleSyms" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Located PName))) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Name])) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NameDisp))))) (C1 (MetaCons "UnboundExpr" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Located PName))) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NameDisp))))) ((:+:) (C1 (MetaCons "UnboundType" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Located PName))) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NameDisp)))) ((:+:) (C1 (MetaCons "OverlappingSyms" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Name])) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NameDisp)))) (C1 (MetaCons "ExpectedValue" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Located PName))) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NameDisp))))))) ((:+:) ((:+:) (C1 (MetaCons "ExpectedType" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Located PName))) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NameDisp)))) (C1 (MetaCons "FixityError" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Located Name))) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Located Name))) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NameDisp)))))) ((:+:) (C1 (MetaCons "InvalidConstraint" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Type PName))) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NameDisp)))) ((:+:) (C1 (MetaCons "MalformedBuiltin" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Type PName))) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 PName)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NameDisp))))) (C1 (MetaCons "BoundReservedType" PrefixI False) ((:*:) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 PName)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Range)))) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Doc)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NameDisp)))))))))

data RenamerWarning Source #

Constructors

SymbolShadowed Name [Name] NameDisp |

Instances

Show RenamerWarning Source # |
Methods showsPrec :: Int -> RenamerWarning -> ShowS # show :: RenamerWarning -> String # showList :: [RenamerWarning] -> ShowS #
Generic RenamerWarning Source # |
Associated Types type Rep RenamerWarning :: * -> * # Methods from :: RenamerWarning -> Rep RenamerWarning x # to :: Rep RenamerWarning x -> RenamerWarning #
NFData RenamerWarning Source # |
Methods rnf :: RenamerWarning -> () #
PP RenamerWarning Source # |
Methods ppPrec :: Int -> RenamerWarning -> Doc Source #
type Rep RenamerWarning Source # |

type Rep RenamerWarning = D1 (MetaData "RenamerWarning" "Cryptol.ModuleSystem.Renamer" "cryptol-2.4.0-CN28BMG3PUFD1lr9WvB1U9" False) (C1 (MetaCons "SymbolShadowed" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Name)) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Name])) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NameDisp)))))

renameVar :: PName -> RenameM Name Source #

renameType :: PName -> RenameM Name Source #

renameModule :: Module PName -> RenameM (NamingEnv, Module Name) Source #