purescript-0.15.15: PureScript Programming Language Compiler

Safe Haskell | None
Language | Haskell2010

Language.PureScript.Sugar.Names

Synopsis

- desugarImports :: (MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadState (Env, UsedImports) m) => Module -> m Module
- type Env = Map ModuleName (SourceSpan, Imports, Exports)
- externsEnv :: (MonadError MultipleErrors m, MonadWriter MultipleErrors m) => Env -> ExternsFile -> m Env
- primEnv :: Env
- 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)
  }
- 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
  }

# Documentation

desugarImports :: (MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadState (Env, UsedImports) m) => Module -> m Module #

Replaces all local names with qualified names.

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.

externsEnv :: (MonadError MultipleErrors m, MonadWriter MultipleErrors m) => Env -> ExternsFile -> m Env #

Create an environment from a collection of externs files

primEnv :: Env #

Environment which only contains the Prim modules.

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 #

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 #