cryptol-3.0.0: Cryptol: The Language of Cryptography

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

Cryptol.Utils.Ident

Contents

- Module names
- Identifiers
- Namespaces
- Original names
- Identifiers for primitives

Description

Synopsis

- data ModPath
  - = TopModule ModName
  - | Nested ModPath Ident
- apPathRoot :: (ModName -> ModName) -> ModPath -> ModPath
- modPathCommon :: ModPath -> ModPath -> Maybe (ModPath, [Ident], [Ident])
- modPathIsOrContains :: ModPath -> ModPath -> Bool
- topModuleFor :: ModPath -> ModName
- modPathSplit :: ModPath -> (ModName, [Ident])
- modPathIsNormal :: ModPath -> Bool
- data ModName
- modNameToText :: ModName -> Text
- textToModName :: Text -> ModName
- modNameChunks :: ModName -> [String]
- modNameChunksText :: ModName -> [Text]
- packModName :: [Text] -> ModName
- preludeName :: ModName
- preludeReferenceName :: ModName
- undefinedModName :: ModName
- floatName :: ModName
- suiteBName :: ModName
- arrayName :: ModName
- primeECName :: ModName
- interactiveName :: ModName
- noModuleName :: ModName
- exprModName :: ModName
- modNameArg :: ModName -> ModName
- modNameIfaceMod :: ModName -> ModName
- modNameToNormalModName :: ModName -> ModName
- modNameIsNormal :: ModName -> Bool
- data Ident
- packIdent :: String -> Ident
- packInfix :: String -> Ident
- unpackIdent :: Ident -> String
- mkIdent :: Text -> Ident
- mkInfix :: Text -> Ident
- isInfixIdent :: Ident -> Bool
- nullIdent :: Ident -> Bool
- identText :: Ident -> Text
- modParamIdent :: Ident -> Ident
- identAnonArg :: Ident -> Ident
- identAnonIfaceMod :: Ident -> Ident
- identIsNormal :: Ident -> Bool
- data Namespace
  - = NSValue
  - | NSType
  - | NSModule
- allNamespaces :: [Namespace]
- data OrigName = OrigName {
  - ogNamespace :: Namespace
  - ogModule :: ModPath
  - ogSource :: OrigSource
  - ogName :: Ident
  }
- data OrigSource
  - = FromDefinition
  - | FromFunctorInst
  - | FromModParam Ident
- ogFromModParam :: OrigName -> Bool
- data PrimIdent = PrimIdent ModName Text
- prelPrim :: Text -> PrimIdent
- floatPrim :: Text -> PrimIdent
- arrayPrim :: Text -> PrimIdent
- suiteBPrim :: Text -> PrimIdent
- primeECPrim :: Text -> PrimIdent

# Module names

data ModPath Source #

Idnetifies a possibly nested module

Constructors

TopModule ModName |
Nested ModPath Ident |

#### Instances

Instances details

Generic ModPath Source # |
Instance details Defined in Cryptol.Utils.Ident Associated Types type Rep ModPath :: Type -> Type Source # Methods from :: ModPath -> Rep ModPath x Source # to :: Rep ModPath x -> ModPath Source #
Show ModPath Source # |
Instance details Defined in Cryptol.Utils.Ident Methods showsPrec :: Int -> ModPath -> ShowS Source # show :: ModPath -> String Source # showList :: [ModPath] -> ShowS Source #
PP ModPath Source # |
Instance details Defined in Cryptol.Utils.PP Methods ppPrec :: Int -> ModPath -> Doc Source #
NFData ModPath Source # |
Instance details Defined in Cryptol.Utils.Ident Methods rnf :: ModPath -> () Source #
Eq ModPath Source # |
Instance details Defined in Cryptol.Utils.Ident Methods (==) :: ModPath -> ModPath -> Bool Source # (/=) :: ModPath -> ModPath -> Bool Source #
Ord ModPath Source # |
Instance details Defined in Cryptol.Utils.Ident Methods compare :: ModPath -> ModPath -> Ordering Source # (<) :: ModPath -> ModPath -> Bool Source # (<=) :: ModPath -> ModPath -> Bool Source # (>) :: ModPath -> ModPath -> Bool Source # (>=) :: ModPath -> ModPath -> Bool Source # max :: ModPath -> ModPath -> ModPath Source # min :: ModPath -> ModPath -> ModPath Source #
type Rep ModPath Source # |

Instance details

Defined in Cryptol.Utils.Ident

type Rep ModPath = D1 ('MetaData "ModPath" "Cryptol.Utils.Ident" "cryptol-3.0.0-DBVDUAjB1JeD0WzkHH4ckn" 'False) (C1 ('MetaCons "TopModule" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModName)) :+: C1 ('MetaCons "Nested" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModPath) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Ident)))

apPathRoot :: (ModName -> ModName) -> ModPath -> ModPath Source #

modPathCommon :: ModPath -> ModPath -> Maybe (ModPath, [Ident], [Ident]) Source #

Compute a common prefix between two module paths, if any. This is basically "anti-unification" of the two paths, where we compute the longest common prefix, and the remaining differences for each module.

modPathIsOrContains :: ModPath -> ModPath -> Bool Source #

Does the first module path contain the second? This returns true if the paths are the same.

topModuleFor :: ModPath -> ModName Source #

modPathSplit :: ModPath -> (ModName, [Ident]) Source #

modPathIsNormal :: ModPath -> Bool Source #

data ModName Source #

Top-level Module names are just text.

#### Instances

Instances details

Generic ModName Source # |
Instance details Defined in Cryptol.Utils.Ident Associated Types type Rep ModName :: Type -> Type Source # Methods from :: ModName -> Rep ModName x Source # to :: Rep ModName x -> ModName Source #
Show ModName Source # |
Instance details Defined in Cryptol.Utils.Ident Methods showsPrec :: Int -> ModName -> ShowS Source # show :: ModName -> String Source # showList :: [ModName] -> ShowS Source #
PP ModName Source # |
Instance details Defined in Cryptol.Utils.PP Methods ppPrec :: Int -> ModName -> Doc Source #
PPName ModName Source # |
Instance details Defined in Cryptol.Utils.PP Methods ppNameFixity :: ModName -> Maybe Fixity Source # ppPrefixName :: ModName -> Doc Source # ppInfixName :: ModName -> Doc Source #
NFData ModName Source # |
Instance details Defined in Cryptol.Utils.Ident Methods rnf :: ModName -> () Source #
Eq ModName Source # |
Instance details Defined in Cryptol.Utils.Ident Methods (==) :: ModName -> ModName -> Bool Source # (/=) :: ModName -> ModName -> Bool Source #
Ord ModName Source # |
Instance details Defined in Cryptol.Utils.Ident Methods compare :: ModName -> ModName -> Ordering Source # (<) :: ModName -> ModName -> Bool Source # (<=) :: ModName -> ModName -> Bool Source # (>) :: ModName -> ModName -> Bool Source # (>=) :: ModName -> ModName -> Bool Source # max :: ModName -> ModName -> ModName Source # min :: ModName -> ModName -> ModName Source #
type Rep ModName Source # |
Instance details Defined in Cryptol.Utils.Ident type Rep ModName

modNameToText :: ModName -> Text Source #

textToModName :: Text -> ModName Source #

Make a normal module name out of text.

modNameChunks :: ModName -> [String] Source #

Break up a module name on the separators, `String` version

modNameChunksText :: ModName -> [Text] Source #

Break up a module name on the separators, `Text` version.

packModName :: [Text] -> ModName Source #

preludeName :: ModName Source #

preludeReferenceName :: ModName Source #

undefinedModName :: ModName Source #

floatName :: ModName Source #

suiteBName :: ModName Source #

arrayName :: ModName Source #

primeECName :: ModName Source #

interactiveName :: ModName Source #

noModuleName :: ModName Source #

exprModName :: ModName Source #

modNameArg :: ModName -> ModName Source #

Change a normal module name to a module name to be used for an anonnymous argument.

modNameIfaceMod :: ModName -> ModName Source #

Change a normal module name to a module name to be used for an anonnymous interface.

modNameToNormalModName :: ModName -> ModName Source #

This is used when we check that the name of a module matches the file where it is defined.

modNameIsNormal :: ModName -> Bool Source #

This is useful when we want to hide anonymous modules.

# Identifiers

data Ident Source #

The type of identifiers. * The boolean flag indicates whether or not they're infix operators. The boolean is present just as cached information from the lexer, and never used during comparisons. * The MaybeAnon indicates if this is an anonymous name

#### Instances

Instances details

IsString Ident Source # |
Instance details Defined in Cryptol.Utils.Ident Methods fromString :: String -> Ident Source #
Generic Ident Source # |
Instance details Defined in Cryptol.Utils.Ident Associated Types type Rep Ident :: Type -> Type Source # Methods from :: Ident -> Rep Ident x Source # to :: Rep Ident x -> Ident Source #
Show Ident Source # |
Instance details Defined in Cryptol.Utils.Ident Methods showsPrec :: Int -> Ident -> ShowS Source # show :: Ident -> String Source # showList :: [Ident] -> ShowS Source #
ShowParseable Ident Source # |
Instance details Defined in Cryptol.TypeCheck.Parseable Methods showParseable :: Ident -> Doc Void Source #
PP Ident Source # |
Instance details Defined in Cryptol.Utils.PP Methods ppPrec :: Int -> Ident -> Doc Source #
NFData Ident Source # |
Instance details Defined in Cryptol.Utils.Ident Methods rnf :: Ident -> () Source #
Eq Ident Source # |
Instance details Defined in Cryptol.Utils.Ident Methods (==) :: Ident -> Ident -> Bool Source # (/=) :: Ident -> Ident -> Bool Source #
Ord Ident Source # |
Instance details Defined in Cryptol.Utils.Ident Methods compare :: Ident -> Ident -> Ordering Source # (<) :: Ident -> Ident -> Bool Source # (<=) :: Ident -> Ident -> Bool Source # (>) :: Ident -> Ident -> Bool Source # (>=) :: Ident -> Ident -> Bool Source # max :: Ident -> Ident -> Ident Source # min :: Ident -> Ident -> Ident Source #
type Rep Ident Source # |
Instance details Defined in Cryptol.Utils.Ident type Rep Ident

packIdent :: String -> Ident Source #

Make a normal (i.e., not anonymous) identifier

packInfix :: String -> Ident Source #

Make a normal (i.e., not anonymous) identifier

unpackIdent :: Ident -> String Source #

mkIdent :: Text -> Ident Source #

Make a normal (i.e., not anonymous) identifier

mkInfix :: Text -> Ident Source #

isInfixIdent :: Ident -> Bool Source #

nullIdent :: Ident -> Bool Source #

identText :: Ident -> Text Source #

modParamIdent :: Ident -> Ident Source #

identAnonArg :: Ident -> Ident Source #

Make an anonymous identifier for the module corresponding to a `where` block in a functor instantiation.

identAnonIfaceMod :: Ident -> Ident Source #

Make an anonymous identifier for the interface corresponding to a `parameter` declaration.

identIsNormal :: Ident -> Bool Source #

# Namespaces

data Namespace Source #

Namespaces for names

Constructors

NSValue |
NSType |
NSModule |

#### Instances

Instances details

Bounded Namespace Source # |
Instance details Defined in Cryptol.Utils.Ident Methods minBound :: Namespace Source # maxBound :: Namespace Source #
Enum Namespace Source # |

Instance details

Defined in Cryptol.Utils.Ident

Methods

succ :: Namespace -> Namespace Source #

pred :: Namespace -> Namespace Source #

toEnum :: Int -> Namespace Source #

fromEnum :: Namespace -> Int Source #

enumFrom :: Namespace -> [Namespace] Source #

enumFromThen :: Namespace -> Namespace -> [Namespace] Source #

enumFromTo :: Namespace -> Namespace -> [Namespace] Source #

enumFromThenTo :: Namespace -> Namespace -> Namespace -> [Namespace] Source #

Generic Namespace Source # |
Instance details Defined in Cryptol.Utils.Ident Associated Types type Rep Namespace :: Type -> Type Source # Methods from :: Namespace -> Rep Namespace x Source # to :: Rep Namespace x -> Namespace Source #
Show Namespace Source # |
Instance details Defined in Cryptol.Utils.Ident Methods showsPrec :: Int -> Namespace -> ShowS Source # show :: Namespace -> String Source # showList :: [Namespace] -> ShowS Source #
PP Namespace Source # |
Instance details Defined in Cryptol.Utils.PP Methods ppPrec :: Int -> Namespace -> Doc Source #
NFData Namespace Source # |
Instance details Defined in Cryptol.Utils.Ident Methods rnf :: Namespace -> () Source #
Eq Namespace Source # |
Instance details Defined in Cryptol.Utils.Ident Methods (==) :: Namespace -> Namespace -> Bool Source # (/=) :: Namespace -> Namespace -> Bool Source #
Ord Namespace Source # |

Instance details

Defined in Cryptol.Utils.Ident

Methods

compare :: Namespace -> Namespace -> Ordering Source #

(<) :: Namespace -> Namespace -> Bool Source #

(<=) :: Namespace -> Namespace -> Bool Source #

(>) :: Namespace -> Namespace -> Bool Source #

(>=) :: Namespace -> Namespace -> Bool Source #

max :: Namespace -> Namespace -> Namespace Source #

min :: Namespace -> Namespace -> Namespace Source #

type Rep Namespace Source # |
Instance details Defined in Cryptol.Utils.Ident type Rep Namespace = D1 ('MetaData "Namespace" "Cryptol.Utils.Ident" "cryptol-3.0.0-DBVDUAjB1JeD0WzkHH4ckn" 'False) (C1 ('MetaCons "NSValue" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NSType" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NSModule" 'PrefixI 'False) (U1 :: Type -> Type)))

allNamespaces :: [Namespace] Source #

# Original names

data OrigName Source #

Identifies an entitiy

Constructors

OrigName |

Fields

- ogNamespace :: Namespace
- ogModule :: ModPath
- ogSource :: OrigSource
- ogName :: Ident

#### Instances

Instances details

Generic OrigName Source # |
Instance details Defined in Cryptol.Utils.Ident Associated Types type Rep OrigName :: Type -> Type Source # Methods from :: OrigName -> Rep OrigName x Source # to :: Rep OrigName x -> OrigName Source #
Show OrigName Source # |
Instance details Defined in Cryptol.Utils.Ident Methods showsPrec :: Int -> OrigName -> ShowS Source # show :: OrigName -> String Source # showList :: [OrigName] -> ShowS Source #
PP OrigName Source # |
Instance details Defined in Cryptol.Utils.PP Methods ppPrec :: Int -> OrigName -> Doc Source #
NFData OrigName Source # |
Instance details Defined in Cryptol.Utils.Ident Methods rnf :: OrigName -> () Source #
Eq OrigName Source # |
Instance details Defined in Cryptol.Utils.Ident Methods (==) :: OrigName -> OrigName -> Bool Source # (/=) :: OrigName -> OrigName -> Bool Source #
Ord OrigName Source # |
Instance details Defined in Cryptol.Utils.Ident Methods compare :: OrigName -> OrigName -> Ordering Source # (<) :: OrigName -> OrigName -> Bool Source # (<=) :: OrigName -> OrigName -> Bool Source # (>) :: OrigName -> OrigName -> Bool Source # (>=) :: OrigName -> OrigName -> Bool Source # max :: OrigName -> OrigName -> OrigName Source # min :: OrigName -> OrigName -> OrigName Source #
type Rep OrigName Source # |

Instance details

Defined in Cryptol.Utils.Ident

type Rep OrigName = D1 ('MetaData "OrigName" "Cryptol.Utils.Ident" "cryptol-3.0.0-DBVDUAjB1JeD0WzkHH4ckn" 'False) (C1 ('MetaCons "OrigName" 'PrefixI 'True) ((S1 ('MetaSel ('Just "ogNamespace") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Namespace) :*: S1 ('MetaSel ('Just "ogModule") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModPath)) :*: (S1 ('MetaSel ('Just "ogSource") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 OrigSource) :*: S1 ('MetaSel ('Just "ogName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Ident))))

data OrigSource Source #

Describes where a top-level name came from

Constructors

FromDefinition |
FromFunctorInst |
FromModParam Ident |

#### Instances

Instances details

Generic OrigSource Source # |
Instance details Defined in Cryptol.Utils.Ident Associated Types type Rep OrigSource :: Type -> Type Source # Methods from :: OrigSource -> Rep OrigSource x Source # to :: Rep OrigSource x -> OrigSource Source #
Show OrigSource Source # |
Instance details Defined in Cryptol.Utils.Ident Methods showsPrec :: Int -> OrigSource -> ShowS Source # show :: OrigSource -> String Source # showList :: [OrigSource] -> ShowS Source #
NFData OrigSource Source # |
Instance details Defined in Cryptol.Utils.Ident Methods rnf :: OrigSource -> () Source #
Eq OrigSource Source # |
Instance details Defined in Cryptol.Utils.Ident Methods (==) :: OrigSource -> OrigSource -> Bool Source # (/=) :: OrigSource -> OrigSource -> Bool Source #
Ord OrigSource Source # |

Instance details

Defined in Cryptol.Utils.Ident

Methods

compare :: OrigSource -> OrigSource -> Ordering Source #

(<) :: OrigSource -> OrigSource -> Bool Source #

(<=) :: OrigSource -> OrigSource -> Bool Source #

(>) :: OrigSource -> OrigSource -> Bool Source #

(>=) :: OrigSource -> OrigSource -> Bool Source #

max :: OrigSource -> OrigSource -> OrigSource Source #

min :: OrigSource -> OrigSource -> OrigSource Source #

type Rep OrigSource Source # |

Instance details

Defined in Cryptol.Utils.Ident

type Rep OrigSource = D1 ('MetaData "OrigSource" "Cryptol.Utils.Ident" "cryptol-3.0.0-DBVDUAjB1JeD0WzkHH4ckn" 'False) (C1 ('MetaCons "FromDefinition" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "FromFunctorInst" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "FromModParam" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Ident))))

ogFromModParam :: OrigName -> Bool Source #

Returns true iff the `ogSource` of the given `OrigName` is `FromModParam`

# Identifiers for primitives

data PrimIdent Source #

A way to identify primitives: we used to use just `Ident`, but this isn't good anymore as now we have primitives in multiple modules. This is used as a key when we need to lookup details about a specific primitive. Also, this is intended to mostly be used internally, so we don't store the fixity flag of the `Ident`

Constructors

PrimIdent ModName Text |

#### Instances

Instances details

Generic PrimIdent Source # |
Instance details Defined in Cryptol.Utils.Ident Associated Types type Rep PrimIdent :: Type -> Type Source # Methods from :: PrimIdent -> Rep PrimIdent x Source # to :: Rep PrimIdent x -> PrimIdent Source #
Show PrimIdent Source # |
Instance details Defined in Cryptol.Utils.Ident Methods showsPrec :: Int -> PrimIdent -> ShowS Source # show :: PrimIdent -> String Source # showList :: [PrimIdent] -> ShowS Source #
PP PrimIdent Source # |
Instance details Defined in Cryptol.Utils.PP Methods ppPrec :: Int -> PrimIdent -> Doc Source #
NFData PrimIdent Source # |
Instance details Defined in Cryptol.Utils.Ident Methods rnf :: PrimIdent -> () Source #
Eq PrimIdent Source # |
Instance details Defined in Cryptol.Utils.Ident Methods (==) :: PrimIdent -> PrimIdent -> Bool Source # (/=) :: PrimIdent -> PrimIdent -> Bool Source #
Ord PrimIdent Source # |

Instance details

Defined in Cryptol.Utils.Ident

Methods

compare :: PrimIdent -> PrimIdent -> Ordering Source #

(<) :: PrimIdent -> PrimIdent -> Bool Source #

(<=) :: PrimIdent -> PrimIdent -> Bool Source #

(>) :: PrimIdent -> PrimIdent -> Bool Source #

(>=) :: PrimIdent -> PrimIdent -> Bool Source #

max :: PrimIdent -> PrimIdent -> PrimIdent Source #

min :: PrimIdent -> PrimIdent -> PrimIdent Source #

type Rep PrimIdent Source # |

Instance details

Defined in Cryptol.Utils.Ident

type Rep PrimIdent = D1 ('MetaData "PrimIdent" "Cryptol.Utils.Ident" "cryptol-3.0.0-DBVDUAjB1JeD0WzkHH4ckn" 'False) (C1 ('MetaCons "PrimIdent" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModName) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

prelPrim :: Text -> PrimIdent Source #

A shortcut to make (non-infix) primitives in the prelude.

floatPrim :: Text -> PrimIdent Source #

arrayPrim :: Text -> PrimIdent Source #

suiteBPrim :: Text -> PrimIdent Source #

primeECPrim :: Text -> PrimIdent Source #