cryptol-2.4.0: Cryptol: The Language of Cryptography

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

Cryptol.ModuleSystem.Name

Contents

- Names
  - Creation
  - Unique Supply
  - PrimMap

Description

Synopsis

- data Name
- data NameInfo
  - = Declared !ModName
  - | Parameter
- nameUnique :: Name -> Int
- nameIdent :: Name -> Ident
- nameInfo :: Name -> NameInfo
- nameLoc :: Name -> Range
- nameFixity :: Name -> Maybe Fixity
- asPrim :: Name -> Maybe Ident
- cmpNameLexical :: Name -> Name -> Ordering
- cmpNameDisplay :: NameDisp -> Name -> Name -> Ordering
- ppLocName :: Name -> Doc
- mkDeclared :: ModName -> Ident -> Maybe Fixity -> Range -> Supply -> (Name, Supply)
- mkParameter :: Ident -> Range -> Supply -> (Name, Supply)
- class Monad m => FreshM m where
- nextUniqueM :: FreshM m => m Int
- data SupplyT m a
- runSupplyT :: Monad m => Supply -> SupplyT m a -> m (a, Supply)
- data Supply
- emptySupply :: Supply
- nextUnique :: Supply -> (Int, Supply)
- data PrimMap = PrimMap {
  - primDecls :: Map Ident Name
  - primTypes :: Map Ident Name
  }
- lookupPrimDecl :: Ident -> PrimMap -> Name
- lookupPrimType :: Ident -> PrimMap -> Name

# Names

data Name Source #

Instances

Eq Name Source # |
Methods (==) :: Name -> Name -> Bool # (/=) :: Name -> Name -> Bool #
Ord Name Source # |
Methods compare :: Name -> Name -> Ordering # (<) :: Name -> Name -> Bool # (<=) :: Name -> Name -> Bool # (>) :: Name -> Name -> Bool # (>=) :: Name -> Name -> Bool # max :: Name -> Name -> Name # min :: Name -> Name -> Name #
Show Name Source # |
Methods showsPrec :: Int -> Name -> ShowS # show :: Name -> String # showList :: [Name] -> ShowS #
Generic Name Source # |
Associated Types type Rep Name :: * -> * # Methods from :: Name -> Rep Name x # to :: Rep Name x -> Name #
NFData Name Source # |
Methods rnf :: Name -> () #
PPName Name Source # |
Methods ppNameFixity :: Name -> Maybe (Assoc, Int) Source # ppPrefixName :: Name -> Doc Source # ppInfixName :: Name -> Doc Source #
PP Name Source # |
Methods ppPrec :: Int -> Name -> Doc Source #
FromDecl (Decl Name) Source # |
Methods toBind :: Decl Name -> Maybe (Bind Name) Source # toTyDecl :: Decl Name -> Maybe TyDecl Source # isTopDecl :: Decl Name -> Bool Source #
FromDecl (TopDecl Name) Source # |
Methods toBind :: TopDecl Name -> Maybe (Bind Name) Source # toTyDecl :: TopDecl Name -> Maybe TyDecl Source # isTopDecl :: TopDecl Name -> Bool Source #
type Rep Name Source # |

type Rep Name = D1 (MetaData "Name" "Cryptol.ModuleSystem.Name" "cryptol-2.4.0-CN28BMG3PUFD1lr9WvB1U9" False) (C1 (MetaCons "Name" PrefixI True) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "nUnique") SourceUnpack SourceStrict DecidedUnpack) (Rec0 Int)) (S1 (MetaSel (Just Symbol "nInfo") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 NameInfo))) ((:*:) (S1 (MetaSel (Just Symbol "nIdent") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Ident)) ((:*:) (S1 (MetaSel (Just Symbol "nFixity") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Fixity))) (S1 (MetaSel (Just Symbol "nLoc") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Range))))))

data NameInfo Source #

Information about the binding site of the name.

Constructors

Declared !ModName | This name refers to a declaration from this module
Parameter | This name is a parameter (function or type)

Instances

Eq NameInfo Source # |
Methods (==) :: NameInfo -> NameInfo -> Bool # (/=) :: NameInfo -> NameInfo -> Bool #
Show NameInfo Source # |
Methods showsPrec :: Int -> NameInfo -> ShowS # show :: NameInfo -> String # showList :: [NameInfo] -> ShowS #
Generic NameInfo Source # |
Associated Types type Rep NameInfo :: * -> * # Methods from :: NameInfo -> Rep NameInfo x # to :: Rep NameInfo x -> NameInfo #
NFData NameInfo Source # |
Methods rnf :: NameInfo -> () #
type Rep NameInfo Source # |
type Rep NameInfo = D1 (MetaData "NameInfo" "Cryptol.ModuleSystem.Name" "cryptol-2.4.0-CN28BMG3PUFD1lr9WvB1U9" False) ((:+:) (C1 (MetaCons "Declared" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 ModName))) (C1 (MetaCons "Parameter" PrefixI False) U1))

nameUnique :: Name -> Int Source #

nameIdent :: Name -> Ident Source #

nameInfo :: Name -> NameInfo Source #

nameLoc :: Name -> Range Source #

nameFixity :: Name -> Maybe Fixity Source #

asPrim :: Name -> Maybe Ident Source #

cmpNameLexical :: Name -> Name -> Ordering Source #

Compare two names lexically.

cmpNameDisplay :: NameDisp -> Name -> Name -> Ordering Source #

Compare two names by the way they would be displayed.

ppLocName :: Name -> Doc Source #

Pretty-print a name with its source location information.

## Creation

mkDeclared :: ModName -> Ident -> Maybe Fixity -> Range -> Supply -> (Name, Supply) Source #

Make a new name for a declaration.

mkParameter :: Ident -> Range -> Supply -> (Name, Supply) Source #

Make a new parameter name.

## Unique Supply

class Monad m => FreshM m where Source #

Minimal complete definition

liftSupply

Methods

liftSupply :: (Supply -> (a, Supply)) -> m a Source #

Instances

FreshM InferM Source # |
Methods liftSupply :: (Supply -> (a, Supply)) -> InferM a Source #
FreshM RenameM Source # |
Methods liftSupply :: (Supply -> (a, Supply)) -> RenameM a Source #
FreshM REPL Source # |
Methods liftSupply :: (Supply -> (a, Supply)) -> REPL a Source #
Monad m => FreshM (SupplyT m) Source # |
Methods liftSupply :: (Supply -> (a, Supply)) -> SupplyT m a Source #
Monad m => FreshM (ModuleT m) Source # |
Methods liftSupply :: (Supply -> (a, Supply)) -> ModuleT m a Source #
FreshM m => FreshM (ReaderT i m) Source # |
Methods liftSupply :: (Supply -> (a, Supply)) -> ReaderT i m a Source #
(Monoid i, FreshM m) => FreshM (WriterT i m) Source # |
Methods liftSupply :: (Supply -> (a, Supply)) -> WriterT i m a Source #
FreshM m => FreshM (StateT i m) Source # |
Methods liftSupply :: (Supply -> (a, Supply)) -> StateT i m a Source #
FreshM m => FreshM (ExceptionT i m) Source # |
Methods liftSupply :: (Supply -> (a, Supply)) -> ExceptionT i m a Source #

nextUniqueM :: FreshM m => m Int Source #

Retrieve the next unique from the supply.

data SupplyT m a Source #

A monad for easing the use of the supply.

Instances

MonadT SupplyT Source # |
Methods lift :: Monad m => m a -> SupplyT m a #
Monad m => Monad (SupplyT m) Source # |
Methods (>>=) :: SupplyT m a -> (a -> SupplyT m b) -> SupplyT m b # (>>) :: SupplyT m a -> SupplyT m b -> SupplyT m b # return :: a -> SupplyT m a # fail :: String -> SupplyT m a #
Monad m => Functor (SupplyT m) Source # |
Methods fmap :: (a -> b) -> SupplyT m a -> SupplyT m b # (<$) :: a -> SupplyT m b -> SupplyT m a #
MonadFix m => MonadFix (SupplyT m) Source # |
Methods mfix :: (a -> SupplyT m a) -> SupplyT m a #
Monad m => Applicative (SupplyT m) Source # |
Methods pure :: a -> SupplyT m a # (<*>) :: SupplyT m (a -> b) -> SupplyT m a -> SupplyT m b # (*>) :: SupplyT m a -> SupplyT m b -> SupplyT m b # (<*) :: SupplyT m a -> SupplyT m b -> SupplyT m a #
Monad m => FreshM (SupplyT m) Source # |
Methods liftSupply :: (Supply -> (a, Supply)) -> SupplyT m a Source #
BaseM m n => BaseM (SupplyT m) n Source # |
Methods inBase :: n a -> SupplyT m a #
RunM m (a, Supply) r => RunM (SupplyT m) a (Supply -> r) Source # |
Methods runM :: SupplyT m a -> Supply -> r #

runSupplyT :: Monad m => Supply -> SupplyT m a -> m (a, Supply) Source #

data Supply Source #

Instances

Show Supply Source # |
Methods showsPrec :: Int -> Supply -> ShowS # show :: Supply -> String # showList :: [Supply] -> ShowS #
Generic Supply Source # |
Associated Types type Rep Supply :: * -> * # Methods from :: Supply -> Rep Supply x # to :: Rep Supply x -> Supply #
NFData Supply Source # |
Methods rnf :: Supply -> () #
RunM m (a, Supply) r => RunM (SupplyT m) a (Supply -> r) Source # |
Methods runM :: SupplyT m a -> Supply -> r #
type Rep Supply Source # |
type Rep Supply = D1 (MetaData "Supply" "Cryptol.ModuleSystem.Name" "cryptol-2.4.0-CN28BMG3PUFD1lr9WvB1U9" False) (C1 (MetaCons "Supply" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Int)))

emptySupply :: Supply Source #

This should only be used once at library initialization, and threaded through the rest of the session. The supply is started at 0x1000 to leave us plenty of room for names that the compiler needs to know about (wired-in constants).

nextUnique :: Supply -> (Int, Supply) Source #

## PrimMap

data PrimMap Source #

A mapping from an identifier defined in some module to its real name.

Constructors

PrimMap |

Fields

- primDecls :: Map Ident Name
- primTypes :: Map Ident Name

Instances

Show PrimMap Source # |
Methods showsPrec :: Int -> PrimMap -> ShowS # show :: PrimMap -> String # showList :: [PrimMap] -> ShowS #
Generic PrimMap Source # |
Associated Types type Rep PrimMap :: * -> * # Methods from :: PrimMap -> Rep PrimMap x # to :: Rep PrimMap x -> PrimMap #
NFData PrimMap Source # |
Methods rnf :: PrimMap -> () #
type Rep PrimMap Source # |
type Rep PrimMap = D1 (MetaData "PrimMap" "Cryptol.ModuleSystem.Name" "cryptol-2.4.0-CN28BMG3PUFD1lr9WvB1U9" False) (C1 (MetaCons "PrimMap" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "primDecls") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Map Ident Name))) (S1 (MetaSel (Just Symbol "primTypes") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Map Ident Name)))))

lookupPrimDecl :: Ident -> PrimMap -> Name Source #

It's assumed that we're looking things up that we know already exist, so this will panic if it doesn't find the name.

lookupPrimType :: Ident -> PrimMap -> Name Source #

It's assumed that we're looking things up that we know already exist, so this will panic if it doesn't find the name.