Language.PureScript.Sugar.Names.Env

purescript-0.15.15: PureScript Programming Language Compiler

Safe Haskell | None
Language | Haskell2010

Language.PureScript.Sugar.Names.Env

Synopsis

- data ImportRecord a = ImportRecord {
  - importName :: Qualified a
  - importSourceModule :: ModuleName
  - importSourceSpan :: SourceSpan
  - importProvenance :: ImportProvenance
  }
- data ImportProvenance
  - = FromImplicit
  - | FromExplicit
  - | Local
  - | Prim
- data Imports = Imports {
  - importedTypes :: ImportMap (ProperName 'TypeName)
  - importedTypeOps :: ImportMap (OpName 'TypeOpName)
  - importedDataConstructors :: ImportMap (ProperName 'ConstructorName)
  - importedTypeClasses :: ImportMap (ProperName 'ClassName)
  - importedValues :: ImportMap Ident
  - importedValueOps :: ImportMap (OpName 'ValueOpName)
  - importedModules :: Set ModuleName
  - importedQualModules :: Set ModuleName
  - importedKinds :: ImportMap (ProperName 'TypeName)
  }
- nullImports :: Imports
- data Exports = Exports {
  - exportedTypes :: Map (ProperName 'TypeName) ([ProperName 'ConstructorName], ExportSource)
  - exportedTypeOps :: Map (OpName 'TypeOpName) ExportSource
  - exportedTypeClasses :: Map (ProperName 'ClassName) ExportSource
  - exportedValues :: Map Ident ExportSource
  - exportedValueOps :: Map (OpName 'ValueOpName) ExportSource
  }
- nullExports :: Exports
- type Env = Map ModuleName (SourceSpan, Imports, Exports)
- primEnv :: Env
- primExports :: Exports
- envModuleExports :: (a, b, Exports) -> Exports
- data ExportMode
  - = Internal
  - | ReExport
- exportType :: MonadError MultipleErrors m => SourceSpan -> ExportMode -> Exports -> ProperName 'TypeName -> [ProperName 'ConstructorName] -> ExportSource -> m Exports
- exportTypeOp :: MonadError MultipleErrors m => SourceSpan -> Exports -> OpName 'TypeOpName -> ExportSource -> m Exports
- exportTypeClass :: MonadError MultipleErrors m => SourceSpan -> ExportMode -> Exports -> ProperName 'ClassName -> ExportSource -> m Exports
- exportValue :: MonadError MultipleErrors m => SourceSpan -> Exports -> Ident -> ExportSource -> m Exports
- exportValueOp :: MonadError MultipleErrors m => SourceSpan -> Exports -> OpName 'ValueOpName -> ExportSource -> m Exports
- checkImportConflicts :: (MonadError MultipleErrors m, MonadWriter MultipleErrors m) => SourceSpan -> ModuleName -> (a -> Name) -> [ImportRecord a] -> m (ModuleName, ModuleName)

# Documentation

data ImportRecord a #

The details for an import: the name of the thing that is being imported (`x` if importing from `A`), the module that the thing was originally defined in (for re-export resolution), and the import provenance (see below).

Constructors

ImportRecord |
Fields importName :: Qualified a importSourceModule :: ModuleName importSourceSpan :: SourceSpan importProvenance :: ImportProvenance

#### Instances

Instances details

Show a => Show (ImportRecord a) # |
Instance details Defined in Language.PureScript.Sugar.Names.Env Methods showsPrec :: Int -> ImportRecord a -> ShowS # show :: ImportRecord a -> String # showList :: [ImportRecord a] -> ShowS #
Eq a => Eq (ImportRecord a) # |
Instance details Defined in Language.PureScript.Sugar.Names.Env Methods (==) :: ImportRecord a -> ImportRecord a -> Bool # (/=) :: ImportRecord a -> ImportRecord a -> Bool #
Ord a => Ord (ImportRecord a) # |
Instance details Defined in Language.PureScript.Sugar.Names.Env Methods compare :: ImportRecord a -> ImportRecord a -> Ordering # (<) :: ImportRecord a -> ImportRecord a -> Bool # (<=) :: ImportRecord a -> ImportRecord a -> Bool # (>) :: ImportRecord a -> ImportRecord a -> Bool # (>=) :: ImportRecord a -> ImportRecord a -> Bool # max :: ImportRecord a -> ImportRecord a -> ImportRecord a # min :: ImportRecord a -> ImportRecord a -> ImportRecord a #

data ImportProvenance #

Used to track how an import was introduced into scope. This allows us to handle the one-open-import special case that allows a name conflict to become a warning rather than being an unresolvable situation.

Constructors

FromImplicit |
FromExplicit |
Local |
Prim |

#### Instances

Instances details

Show ImportProvenance # |
Instance details Defined in Language.PureScript.Sugar.Names.Env Methods showsPrec :: Int -> ImportProvenance -> ShowS # show :: ImportProvenance -> String # showList :: [ImportProvenance] -> ShowS #
Eq ImportProvenance # |
Instance details Defined in Language.PureScript.Sugar.Names.Env Methods (==) :: ImportProvenance -> ImportProvenance -> Bool # (/=) :: ImportProvenance -> ImportProvenance -> Bool #
Ord ImportProvenance # |
Instance details Defined in Language.PureScript.Sugar.Names.Env Methods compare :: ImportProvenance -> ImportProvenance -> Ordering # (<) :: ImportProvenance -> ImportProvenance -> Bool # (<=) :: ImportProvenance -> ImportProvenance -> Bool # (>) :: ImportProvenance -> ImportProvenance -> Bool # (>=) :: ImportProvenance -> ImportProvenance -> Bool # max :: ImportProvenance -> ImportProvenance -> ImportProvenance # min :: ImportProvenance -> ImportProvenance -> ImportProvenance #

data Imports #

The imported declarations for a module, including the module's own members.

Constructors

Imports |
Fields importedTypes :: ImportMap (ProperName 'TypeName) Local names for types within a module mapped to their qualified names importedTypeOps :: ImportMap (OpName 'TypeOpName) Local names for type operators within a module mapped to their qualified names importedDataConstructors :: ImportMap (ProperName 'ConstructorName) Local names for data constructors within a module mapped to their qualified names importedTypeClasses :: ImportMap (ProperName 'ClassName) Local names for classes within a module mapped to their qualified names importedValues :: ImportMap Ident Local names for values within a module mapped to their qualified names importedValueOps :: ImportMap (OpName 'ValueOpName) Local names for value operators within a module mapped to their qualified names importedModules :: Set ModuleName The name of modules that have been imported into the current scope that can be re-exported. If a module is imported with `as` qualification, the `as` name appears here, otherwise the original name. importedQualModules :: Set ModuleName The "as" names of modules that have been imported qualified. importedKinds :: ImportMap (ProperName 'TypeName) Local names for kinds within a module mapped to their qualified names

#### Instances

Instances details

Show Imports # |
Instance details Defined in Language.PureScript.Sugar.Names.Env Methods showsPrec :: Int -> Imports -> ShowS # show :: Imports -> String # showList :: [Imports] -> ShowS #

nullImports :: Imports #

data Exports #

The exported declarations from a module.

Constructors

Exports |
Fields exportedTypes :: Map (ProperName 'TypeName) ([ProperName 'ConstructorName], ExportSource) The exported types along with the module they originally came from. exportedTypeOps :: Map (OpName 'TypeOpName) ExportSource The exported type operators along with the module they originally came from. exportedTypeClasses :: Map (ProperName 'ClassName) ExportSource The exported classes along with the module they originally came from. exportedValues :: Map Ident ExportSource The exported values along with the module they originally came from. exportedValueOps :: Map (OpName 'ValueOpName) ExportSource The exported value operators along with the module they originally came from.

#### Instances

Instances details

Show Exports # |
Instance details Defined in Language.PureScript.Sugar.Names.Env Methods showsPrec :: Int -> Exports -> ShowS # show :: Exports -> String # showList :: [Exports] -> ShowS #

nullExports :: Exports #

An empty `Exports` value.

type Env = Map ModuleName (SourceSpan, Imports, Exports) #

The imports and exports for a collection of modules. The `SourceSpan` is used to store the source location of the module with a given name, used to provide useful information when there is a duplicate module definition.

primEnv :: Env #

Environment which only contains the Prim modules.

primExports :: Exports #

The exported types from the `Prim` module

envModuleExports :: (a, b, Exports) -> Exports #

Extracts the `Exports` from an `Env` value.

data ExportMode #

When updating the `Exports` the behaviour is slightly different depending on whether we are exporting values defined within the module or elaborating re-exported values. This type is used to indicate which behaviour should be used.

Constructors

Internal |
ReExport |

#### Instances

Instances details

Show ExportMode # |
Instance details Defined in Language.PureScript.Sugar.Names.Env Methods showsPrec :: Int -> ExportMode -> ShowS # show :: ExportMode -> String # showList :: [ExportMode] -> ShowS #
Eq ExportMode # |
Instance details Defined in Language.PureScript.Sugar.Names.Env Methods (==) :: ExportMode -> ExportMode -> Bool # (/=) :: ExportMode -> ExportMode -> Bool #

exportType :: MonadError MultipleErrors m => SourceSpan -> ExportMode -> Exports -> ProperName 'TypeName -> [ProperName 'ConstructorName] -> ExportSource -> m Exports #

Safely adds a type and its data constructors to some exports, returning an error if a conflict occurs.

exportTypeOp :: MonadError MultipleErrors m => SourceSpan -> Exports -> OpName 'TypeOpName -> ExportSource -> m Exports #

Safely adds a type operator to some exports, returning an error if a conflict occurs.

exportTypeClass :: MonadError MultipleErrors m => SourceSpan -> ExportMode -> Exports -> ProperName 'ClassName -> ExportSource -> m Exports #

Safely adds a class to some exports, returning an error if a conflict occurs.

exportValue :: MonadError MultipleErrors m => SourceSpan -> Exports -> Ident -> ExportSource -> m Exports #

Safely adds a value to some exports, returning an error if a conflict occurs.

exportValueOp :: MonadError MultipleErrors m => SourceSpan -> Exports -> OpName 'ValueOpName -> ExportSource -> m Exports #

Safely adds a value operator to some exports, returning an error if a conflict occurs.

checkImportConflicts :: (MonadError MultipleErrors m, MonadWriter MultipleErrors m) => SourceSpan -> ModuleName -> (a -> Name) -> [ImportRecord a] -> m (ModuleName, ModuleName) #

When reading a value from the imports, check that there are no conflicts in scope.