ddc-core-0.4.2.1: Disciplined Disciple Compiler core language and type checker.

Safe HaskellSafe
LanguageHaskell98

DDC.Core.Module

Contents

Synopsis

Modules

data Module a n Source

A module can be mutually recursive with other modules.

Constructors

ModuleCore 

Fields

moduleName :: !ModuleName

Name of this module.

moduleIsHeader :: !Bool

Whether this is a module header only. Module headers contain type definitions, as well as imports and exports, but no function definitions. Module headers are used in interface files.

moduleExportTypes :: ![(n, ExportSource n)]

Kinds of exported types.

moduleExportValues :: ![(n, ExportSource n)]

Types of exported values.

moduleImportTypes :: ![(n, ImportType n)]

Define imported types.

moduleImportCaps :: ![(n, ImportCap n)]

Define imported capabilities.

moduleImportValues :: ![(n, ImportValue n)]

Define imported values.

moduleImportDataDefs :: ![DataDef n]

Data defs imported from other modules.

moduleDataDefsLocal :: ![DataDef n]

Data types defined in this module.

moduleBody :: !(Exp a n)

The module body consists of some let-bindings wrapping a unit data constructor. We're only interested in the bindings, with the unit being just a place-holder.

isMainModule :: Module a n -> Bool Source

Check if this is the Main module.

moduleDataDefs :: Ord n => Module a n -> DataDefs n Source

Get the data type definitions visible in a module.

moduleKindEnv :: Ord n => Module a n -> KindEnv n Source

Get the top-level kind environment of a module, from its imported types.

moduleTypeEnv :: Ord n => Module a n -> TypeEnv n Source

Get the top-level type environment of a module, from its imported values.

moduleTopBinds :: Ord n => Module a n -> Set n Source

Get the set of top-level value bindings in a module.

moduleTopBindTypes :: Ord n => Module a n -> Map n (Type n) Source

Get a map of named top-level bindings to their types.

mapTopBinds :: (Bind n -> Exp a n -> b) -> Module a n -> [b] Source

Apply a function to all the top-level bindings in a module, producing a list of the results.

Module maps

type ModuleMap a n = Map ModuleName (Module a n) Source

Map of module names to modules.

modulesExportTypes :: Ord n => ModuleMap a n -> KindEnv n -> KindEnv n Source

Add the kind environment exported by all these modules to the given one.

modulesExportValues :: Ord n => ModuleMap a n -> TypeEnv n -> TypeEnv n Source

Add the type environment exported by all these modules to the given one.

Module Names

data ModuleName Source

A hierarchical module name.

Constructors

ModuleName [String] 

readModuleName :: String -> Maybe ModuleName Source

Read a string like M3 as a module name.

isMainModuleName :: ModuleName -> Bool Source

Check whether this is the name of the "Main" module.

Qualified names.

data QualName n Source

A fully qualified name, including the name of the module it is from.

Constructors

QualName ModuleName n 

Instances

Export Definitions

data ExportSource n Source

Define thing exported from a module.

Constructors

ExportSourceLocal

A name defined in this module, with an explicit type.

ExportSourceLocalNoType

A named defined in this module, without a type attached. We use this version for source language where we infer the type of the exported thing.

takeTypeOfExportSource :: ExportSource n -> Maybe (Type n) Source

Take the type of an imported thing, if there is one.

mapTypeOfExportSource :: (Type n -> Type n) -> ExportSource n -> ExportSource n Source

Apply a function to any type in an ExportSource.

Import Definitions

Import Types

data ImportType n Source

Define a foreign type being imported into a module.

Constructors

ImportTypeAbstract

Type imported abstractly.

Used for phantom types of kind Data, as well as regions, effects, and any other type that does not have kind Data. When a type is imported abstractly it has no associated values, so we can just say that we have the type without worrying about how to represent its associated values.

ImportTypeBoxed

Type of some boxed data.

The objects follow the standard heap object layout, but the code that constructs and destructs them may have been written in a different language.

This is used when importing data types defined in Salt modules.

Fields

importTypeBoxed :: !(Kind n)
 

kindOfImportType :: ImportType n -> Kind n Source

Take the kind of an ImportType.

mapKindOfImportType :: (Kind n -> Kind n) -> ImportType n -> ImportType n Source

Apply a function to the kind of an ImportType

Import Capabilities

data ImportCap n Source

Define a foreign capability being imported into a module.

Constructors

ImportCapAbstract

Capability imported abstractly. For capabilities like (Read r) for some top-level region r we can just say that we have the capability.

Fields

importCapAbstractType :: !(Type n)
 

typeOfImportCap :: ImportCap n -> Type n Source

Take the type of an ImportCap.

mapTypeOfImportCap :: (Type n -> Type n) -> ImportCap n -> ImportCap n Source

Apply a function to the type in an ImportCapability.

Import Types

data ImportValue n Source

Define a foreign value being imported into a module.

Constructors

ImportValueModule

Value imported from a module that we compiled ourselves.

Fields

importValueModuleName :: !ModuleName

Name of the module that we're importing from.

importValueModuleVar :: !n

Name of the the value that we're importing.

importValueModuleType :: !(Type n)

Type of the value that we're importing.

importValueModuleArity :: !(Maybe (Int, Int, Int))

Calling convention for this value, including the number of type parameters, value parameters, and boxings.

ImportValueSea

Value imported via the C calling convention.

Fields

importValueSeaVar :: !String

Name of the symbol being imported. This can be different from the name that we give it in the core language.

importValueSeaType :: !(Type n)

Type of the value that we're importing.

typeOfImportValue :: ImportValue n -> Type n Source

Take the type of an imported thing.

mapTypeOfImportValue :: (Type n -> Type n) -> ImportValue n -> ImportValue n Source

Apply a function to the type in an ImportValue.