cryptol-2.8.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 | Haskell2010

Cryptol.ModuleSystem.NamingEnv

Description

Synopsis

- data NamingEnv = NamingEnv {
  - neExprs :: !(Map PName [Name])
  - neTypes :: !(Map PName [Name])
  }
- lookupValNames :: PName -> NamingEnv -> [Name]
- lookupTypeNames :: PName -> NamingEnv -> [Name]
- merge :: [Name] -> [Name] -> [Name]
- toPrimMap :: NamingEnv -> PrimMap
- toNameDisp :: NamingEnv -> NameDisp
- visibleNames :: NamingEnv -> (Set Name, Set Name)
- qualify :: ModName -> NamingEnv -> NamingEnv
- filterNames :: (PName -> Bool) -> NamingEnv -> NamingEnv
- singletonT :: PName -> Name -> NamingEnv
- singletonE :: PName -> Name -> NamingEnv
- shadowing :: NamingEnv -> NamingEnv -> NamingEnv
- travNamingEnv :: Applicative f => (Name -> f Name) -> NamingEnv -> f NamingEnv
- data InModule a = InModule !ModName a
- namingEnv' :: BindsNames a => a -> Supply -> (NamingEnv, Supply)
- newTop :: FreshM m => ModName -> PName -> Maybe Fixity -> Range -> m Name
- newLocal :: FreshM m => PName -> Range -> m Name
- newtype BuildNamingEnv = BuildNamingEnv {
  - runBuild :: SupplyT Id NamingEnv
  }
- class BindsNames a where
  - namingEnv :: a -> BuildNamingEnv
- interpImport :: Import -> IfaceDecls -> NamingEnv
- unqualifiedEnv :: IfaceDecls -> NamingEnv
- modParamsNamingEnv :: IfaceParams -> NamingEnv
- data ImportIface = ImportIface Import Iface

# Documentation

data NamingEnv Source #

Constructors

NamingEnv |

Fields

- neExprs :: !(Map PName [Name])

  Expr renaming environment

- neTypes :: !(Map PName [Name])

  Type renaming environment

#### Instances

Instances details

Show NamingEnv Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods showsPrec :: Int -> NamingEnv -> ShowS Source # show :: NamingEnv -> String Source # showList :: [NamingEnv] -> ShowS Source #
Generic NamingEnv Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Associated Types type Rep NamingEnv :: Type -> Type Source # Methods from :: NamingEnv -> Rep NamingEnv x Source # to :: Rep NamingEnv x -> NamingEnv Source #
Semigroup NamingEnv Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods (<>) :: NamingEnv -> NamingEnv -> NamingEnv Source # sconcat :: NonEmpty NamingEnv -> NamingEnv Source # stimes :: Integral b => b -> NamingEnv -> NamingEnv Source #
Monoid NamingEnv Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods mempty :: NamingEnv Source # mappend :: NamingEnv -> NamingEnv -> NamingEnv Source # mconcat :: [NamingEnv] -> NamingEnv Source #
NFData NamingEnv Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods rnf :: NamingEnv -> () Source #
BindsNames NamingEnv Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods namingEnv :: NamingEnv -> BuildNamingEnv Source #
type Rep NamingEnv Source # |

Instance details

Defined in Cryptol.ModuleSystem.NamingEnv

type Rep NamingEnv = D1 ('MetaData "NamingEnv" "Cryptol.ModuleSystem.NamingEnv" "cryptol-2.8.0-11Z6ZaBuQbo1UTYpHYMeUg" 'False) (C1 ('MetaCons "NamingEnv" 'PrefixI 'True) (S1 ('MetaSel ('Just "neExprs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map PName [Name])) :*: S1 ('MetaSel ('Just "neTypes") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map PName [Name]))))

lookupValNames :: PName -> NamingEnv -> [Name] Source #

Return a list of value-level names to which this parsed name may refer.

lookupTypeNames :: PName -> NamingEnv -> [Name] Source #

Return a list of type-level names to which this parsed name may refer.

merge :: [Name] -> [Name] -> [Name] Source #

Merge two name maps, collapsing cases where the entries are the same, and producing conflicts otherwise.

toPrimMap :: NamingEnv -> PrimMap Source #

Generate a mapping from `Ident` to `Name` for a given naming environment.

toNameDisp :: NamingEnv -> NameDisp Source #

Generate a display format based on a naming environment.

visibleNames :: NamingEnv -> (Set Name, Set Name) Source #

Produce sets of visible names for types and declarations.

NOTE: if entries in the NamingEnv would have produced a name clash, they will be omitted from the resulting sets.

qualify :: ModName -> NamingEnv -> NamingEnv Source #

Qualify all symbols in a `NamingEnv` with the given prefix.

filterNames :: (PName -> Bool) -> NamingEnv -> NamingEnv Source #

singletonT :: PName -> Name -> NamingEnv Source #

Singleton type renaming environment.

singletonE :: PName -> Name -> NamingEnv Source #

Singleton expression renaming environment.

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

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

travNamingEnv :: Applicative f => (Name -> f Name) -> NamingEnv -> f NamingEnv Source #

data InModule a Source #

Constructors

InModule !ModName a |

#### Instances

Instances details

Functor InModule Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods fmap :: (a -> b) -> InModule a -> InModule b Source # (<$) :: a -> InModule b -> InModule a Source #
Foldable InModule Source # |

Instance details

Defined in Cryptol.ModuleSystem.NamingEnv

Methods

fold :: Monoid m => InModule m -> m Source #

foldMap :: Monoid m => (a -> m) -> InModule a -> m Source #

foldMap' :: Monoid m => (a -> m) -> InModule a -> m Source #

foldr :: (a -> b -> b) -> b -> InModule a -> b Source #

foldr' :: (a -> b -> b) -> b -> InModule a -> b Source #

foldl :: (b -> a -> b) -> b -> InModule a -> b Source #

foldl' :: (b -> a -> b) -> b -> InModule a -> b Source #

foldr1 :: (a -> a -> a) -> InModule a -> a Source #

foldl1 :: (a -> a -> a) -> InModule a -> a Source #

toList :: InModule a -> [a] Source #

null :: InModule a -> Bool Source #

length :: InModule a -> Int Source #

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

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

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

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

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

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

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

Generate a `NamingEnv` using an explicit supply.

newTop :: FreshM m => ModName -> PName -> Maybe Fixity -> Range -> m Name Source #

newLocal :: FreshM m => PName -> Range -> m Name Source #

newtype BuildNamingEnv Source #

Constructors

BuildNamingEnv |

Fields

- runBuild :: SupplyT Id NamingEnv

#### Instances

Instances details

Semigroup BuildNamingEnv Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods (<>) :: BuildNamingEnv -> BuildNamingEnv -> BuildNamingEnv Source # sconcat :: NonEmpty BuildNamingEnv -> BuildNamingEnv Source # stimes :: Integral b => b -> BuildNamingEnv -> BuildNamingEnv Source #
Monoid BuildNamingEnv Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods mempty :: BuildNamingEnv Source # mappend :: BuildNamingEnv -> BuildNamingEnv -> BuildNamingEnv Source # mconcat :: [BuildNamingEnv] -> BuildNamingEnv Source #

class BindsNames a where Source #

Things that define exported names.

Methods

namingEnv :: a -> BuildNamingEnv Source #

#### Instances

Instances details

BindsNames ImportIface Source # | Produce a naming environment from an interface file, that contains a mapping only from unqualified names to qualified ones.
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods namingEnv :: ImportIface -> BuildNamingEnv Source #
BindsNames NamingEnv Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods namingEnv :: NamingEnv -> BuildNamingEnv Source #
BindsNames a => BindsNames [a] Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods namingEnv :: [a] -> BuildNamingEnv Source #
BindsNames a => BindsNames (Maybe a) Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods namingEnv :: Maybe a -> BuildNamingEnv Source #
BindsNames (TParam PName) Source # | Generate the naming environment for a type parameter.
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods namingEnv :: TParam PName -> BuildNamingEnv Source #
BindsNames (Schema PName) Source # | Generate a type renaming environment from the parameters that are bound by this schema.
Instance details Defined in Cryptol.ModuleSystem.NamingEnv 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.
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods namingEnv :: Module PName -> BuildNamingEnv Source #
BindsNames (InModule (PrimType PName)) Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods namingEnv :: InModule (PrimType PName) -> BuildNamingEnv Source #
BindsNames (InModule (Newtype PName)) Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods namingEnv :: InModule (Newtype PName) -> BuildNamingEnv Source #
BindsNames (InModule (Bind PName)) Source # | Introduce the name
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods namingEnv :: InModule (Bind PName) -> BuildNamingEnv Source #
BindsNames (InModule (ParameterFun PName)) Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods namingEnv :: InModule (ParameterFun PName) -> BuildNamingEnv Source #
BindsNames (InModule (ParameterType PName)) Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods namingEnv :: InModule (ParameterType PName) -> BuildNamingEnv Source #
BindsNames (InModule (Decl PName)) Source # | The naming environment for a single declaration.
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods namingEnv :: InModule (Decl PName) -> BuildNamingEnv Source #
BindsNames (InModule (TopDecl PName)) Source # |
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods namingEnv :: InModule (TopDecl PName) -> BuildNamingEnv Source #

interpImport :: Import -> IfaceDecls -> NamingEnv Source #

Interpret an import in the context of an interface, to produce a name environment for the renamer, and a `NameDisp` for pretty-printing.

unqualifiedEnv :: IfaceDecls -> NamingEnv Source #

Generate a naming environment from a declaration interface, where none of the names are qualified.

modParamsNamingEnv :: IfaceParams -> NamingEnv Source #

Compute an unqualified naming environment, containing the various module parameters.

data ImportIface Source #

Constructors

ImportIface Import Iface |

#### Instances

Instances details

BindsNames ImportIface Source # | Produce a naming environment from an interface file, that contains a mapping only from unqualified names to qualified ones.
Instance details Defined in Cryptol.ModuleSystem.NamingEnv Methods namingEnv :: ImportIface -> BuildNamingEnv Source #