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

Safe HaskellSafe-Inferred

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.

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

Kinds of exported types.

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

Types of exported values.

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

Kinds of imported types, along with the name of the module they are from. These imports come from a Disciple module, that we've compiled ourself.

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

Types of imported values, along with the name of the module they are from. These imports come from a Disciple module, that we've compiled ourself.

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.

Instances

isMainModule :: Module a n -> BoolSource

Check if this is the Main module.

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

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

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

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

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

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.

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 nSource

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

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

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

Module Names

data QualName n Source

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

Constructors

QualName ModuleName n 

Instances

Show n => Show (QualName n) 
NFData n => NFData (QualName n) 

isMainModuleName :: ModuleName -> BoolSource

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

Export Sources

data ExportSource n Source

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 nSource

Apply a function to any type in an ExportSource.

Import Sources

data ImportSource n Source

Source of some imported thing.

Constructors

ImportSourceAbstract

A type imported abstractly. It may be defined in a foreign language, but the Disciple program treats it abstractly.

ImportSourceModule

Something imported from a Disciple module that we compiled ourself.

ImportSourceSea

Something imported via the C calling convention.

typeOfImportSource :: ImportSource n -> Type nSource

Take the type of an imported thing.

mapTypeOfImportSource :: (Type n -> Type n) -> ImportSource n -> ImportSource nSource

Apply a function to the type in an ImportSource.