7.10  Module types (module specifications) (2024)

  • 7.10.1Simple module types
  • 7.10.2Signatures
  • 7.10.3Functor types
  • 7.10.4The with operator

Module types are the module-level equivalent of type expressions: theyspecify the general shape and type properties of modules.

module-type::=modtype-path
sig{specification[;;]}end
functor(module-name:module-type)->module-type
module-type->module-type
module-typewithmod-constraint{andmod-constraint}
(module-type)
mod-constraint::=type[type-params]typeconstrtype-equation{type-constraint}
modulemodule-path=extended-module-path
specification::=valvalue-name:typexpr
externalvalue-name:typexpr=external-declaration
type-definition
exceptionconstr-decl
class-specification
classtype-definition
modulemodule-name:module-type
modulemodule-name{(module-name:module-type)}:module-type
moduletypemodtype-name
moduletypemodtype-name=module-type
openmodule-path
includemodule-type

See also the following language extensions:recovering the type of a module,substitution inside a signature,type-level module aliases,attributes,extension nodes andgenerative functors.

7.10.1Simple module types

The expression modtype-path is equivalent to the module type boundto the name modtype-path.The expression ( module-type ) denotes the same type asmodule-type.

7.10.2Signatures

Signatures are type specifications for structures. Signaturessigend are collections of type specifications for valuenames, type names, exceptions, module names and module type names. Astructure will match a signature if the structure provides definitions(implementations) for all the names specified in the signature (andpossibly more), and these definitions meet the type requirements givenin the signature.

An optional ;; is allowed after each specification in asignature. It serves as a syntactic separator with no semanticmeaning.

Value specifications

A specification of a value component in a signature is writtenval value-name : typexpr, where value-name is the name of thevalue and typexpr its expected type.

The form external value-name : typexpr = external-declarationis similar, except that it requires in addition the name to beimplemented as the external function specified in external-declaration(see chapter20).

Type specifications

A specification of one or several type components in a signature iswritten type typedef { and typedef } and consists of a sequenceof mutually recursive definitions of type names.

Each type definition in the signature specifies an optional typeequation = typexpr and an optional type representation= constr-decl … or = { field-decl}.The implementation of the type name in a matching structure mustbe compatible with the type expression specified in the equation (ifgiven), and have the specified representation (if given). Conversely,users of that signature will be able to rely on the type equationor type representation, if given. More precisely, we have thefollowing four situations:

Abstract type: no equation, no representation.

Names that are defined as abstract types in a signature can beimplemented in a matching structure by any kind of type definition(provided it has the same number of type parameters). The exactimplementation of the type will be hidden to the users of thestructure. In particular, if the type is implemented as a variant typeor record type, the associated constructors and fields will not beaccessible to the users; if the type is implemented as anabbreviation, the type equality between the type name and theright-hand side of the abbreviation will be hidden from the users of thestructure. Users of the structure consider that type as incompatiblewith any other type: a fresh type has been generated.
Type abbreviation: an equation = typexpr, no representation.

The type name must be implemented by a type compatible with typexpr.All users of the structure know that the type name iscompatible with typexpr.
New variant type or record type: no equation, a representation.

The type name must be implemented by a variant type or record typewith exactly the constructors or fields specified. All users of thestructure have access to the constructors or fields, and can use themto create or inspect values of that type. However, users of thestructure consider that type as incompatible with any other type: afresh type has been generated.
Re-exported variant type or record type: an equation,a representation.

This case combines the previous two: the representation of the type ismade visible to all users, and no fresh type is generated.

Exception specification

The specification exception constr-decl in a signature requires thematching structure to provide an exception with the name and argumentsspecified in the definition, and makes the exception available to allusers of the structure.

Class specifications

A specification of one or several classes in a signature is writtenclass class-spec { and class-spec } and consists of a sequenceof mutually recursive definitions of class names.

Class specifications are described more precisely insection7.9.4.

Class type specifications

A specification of one or several classe types in a signature iswritten class type classtype-def { and classtype-def } andconsists of a sequence of mutually recursive definitions of class typenames. Class type specifications are described more precisely insection7.9.5.

Module specifications

A specification of a module component in a signature is writtenmodule module-name : module-type, where module-name is thename of the module component and module-type its expected type.Modules can be nested arbitrarily; in particular, functors can appearas components of structures and functor types as components ofsignatures.

For specifying a module component that is a functor, one may write

module module-name ( name1 : module-type1 )( namen : module-typen ): module-type

instead of

module module-name :functor ( name1 : module-type1 ) ->-> module-type

Module type specifications

A module type component of a signature can be specified either as amanifest module type or as an abstract module type.

An abstract module type specificationmodule type modtype-name allows the name modtype-name to beimplemented by any module type in a matching signature, but hides theimplementation of the module type to all users of the signature.

A manifest module type specificationmodule type modtype-name = module-typerequires the name modtype-name to be implemented by the module typemodule-type in a matching signature, but makes the equality betweenmodtype-name and module-type apparent to all users of the signature.

Opening a module path

The expression open module-path in a signature does not specifyany components. It simply affects the parsing of the following itemsof the signature, allowing components of the module denoted bymodule-path to be referred to by their simple names name instead ofpath accesses module-path . name. The scope of the openstops at the end of the signature expression.

Including a signature

The expression include module-type in a signature performs textualinclusion of the components of the signature denoted by module-type.It behaves as if the components of the included signature were copiedat the location of the include. The module-type argument mustrefer to a module type that is a signature, not a functor type.

7.10.3Functor types

The module type expressionfunctor ( module-name : module-type1 ) -> module-type2is the type of functors (functions from modules to modules) that takeas argument a module of type module-type1 and return as result amodule of type module-type2. The module type module-type2 canuse the name module-name to refer to type components of the actualargument of the functor. If the type module-type2 does notdepend on type components of module-name, the module type expressioncan be simplified with the alternative short syntax module-type1 -> module-type2 .No restrictions are placed on the type of the functor argument; inparticular, a functor may take another functor as argument(“higher-order” functor).

7.10.4The with operator

Assuming module-type denotes a signature, the expressionmodule-type with mod-constraint { and mod-constraint } denotesthe same signature where type equations have been added to some of thetype specifications, as described by the constraints following thewith keyword. The constraint type [type-parameters] typeconstr= typexpr adds the type equation = typexpr to the specificationof the type component named typeconstr of the constrained signature.The constraint module module-path = extended-module-path addstype equations to all type components of the sub-structure denoted bymodule-path, making them equivalent to the corresponding typecomponents of the structure denoted by extended-module-path.

For instance, if the module type name S is bound to the signature

 sig type t module M: (sig type u end) end

then S with type t=int denotes the signature

 sig type t=int module M: (sig type u end) end

and S with module M = N denotes the signature

 sig type t module M: (sig type u=N.u end) end

A functor taking two arguments of type S that share their t componentis written

 functor (A: S) (B: S with type t = A.t) ...

Constraints are added left to right. After each constraint has beenapplied, the resulting signature must be a subtype of the signaturebefore the constraint was applied. Thus, the with operator canonly add information on the type components of a signature, but neverremove information.

7.10  Module types (module specifications) (2024)

FAQs

What are the 3 types of modules? ›

The three kind of modules are Form Modules, Standard Modules and Class Modules.

What are module specifications? ›

A module specification contains information about an individual module. It details the aims and learning outcomes of the module, in addition to the teaching, learning and assessment methods. It includes a summary of content and a summary of methods and frequency of teaching.

What does module type mean? ›

Module types are the module-level equivalent of type expressions: they specify the general shape and type properties of modules. module-type. ::= modtype-path.

What are the 4 modules? ›

DBT Skills training is made up of four modules: core mindfulness, distress tolerance, emotion regulation, and interpersonal effectiveness. They are designed to specifically assist individuals in better managing behaviors, emotions and thoughts.

What are five examples of modules? ›

Adobe Workfront Fusion distinguishes five types of modules: action modules, search modules, trigger modules, aggregators, and iterators. Aggregators and Iterators are for advanced scenarios.

What is module interface specification? ›

Interface specifications provide the standardized mechanism in which subsystems can effectively communicate with each other and enable them to operate as independent modules that, when collectively implemented, support the entire CM technical reference model.

What are the basic components of a module? ›

3 Module components
  • a title that concisely and clearly describes the session contents.
  • learning outcomes, each tested by at least one SAQ (see below)
  • an introduction that lays out what will be covered in the study session.
  • core content, text with illustrations, diagrams, graphs, examples etc.

What are module details? ›

Each module has its own learning outcomes, syllabus, assessment schedule and a unique code. The code is made up of a subject code (usually four letters) which shows you which school is offering the module and a module number (usually four digits).

What does type module mean? ›

JavaScript modules allow you to break up your code into separate files. This makes it easier to maintain a code-base. Modules are imported from external files with the import statement. Modules also rely on type="module" in the <script> tag.

What is a module example? ›

For hardware, a module is an assembly of parts designed to be added and removed from a larger system easily. An example of a hardware module is a stick of RAM. Most modules are not functional on their own. They need to be connected to a larger system or be part of a system made up of several modules.

What is a basic module? ›

Basic modules are those that send altered or entirely new requests to the crawler and register callbacks to handle the responses.

What are the three parts of a module? ›

3 Module components
  • a title that concisely and clearly describes the session contents.
  • an introduction that lays out what will be covered in the study session.
  • learning outcomes, each tested by at least one SAQ (see below)
  • core content, text with illustrations, diagrams, graphs, examples etc.

What are the common modules? ›

Common modules are modules frequently used in the content editor. You can add common modules to posts and pages created with most theme templates or coded templates that include drag and drop areas.

What are basic modules? ›

Basic modules are those that send altered or entirely new requests to the crawler and register callbacks to handle the responses.

What are the major modules? ›

Major module means a defined set of modules in each year of study that is taken to third-year level, all relating to a single discipline.

Top Articles
What Should You Do If Your Spouse Empties Your Bank Account During A Divorce?
FHA Loan Limits for 2024 | LendingTree
Fiat 600e: Dolce Vita auf elektrisch
Retail Space For Rent Craigslist
Tiffany's Breakfast Portage
Gladys Le Da Flores A Su Mamá. Correct Incorrect
Craigslist In Lakeland
Jacob Chapel Live Stream
Nyc Peep Show 2022
Farmers And Merchants Bank Broadway Va
National Weather Service Monterey
Lakers Game Summary
Krystal Murphy Below Deck Net Worth
Comcast Business Sign In
Learning The Hard Way Chapter 4
Panic at the disco: Persona 4 Dancing All Night review | Technobubble
Truecarcin
Experience the Convenience of Po Box 790010 St Louis Mo
Weather | Livingston Daily Voice
2012 Buick Lacrosse Serpentine Belt Diagram
Missing 2023 Showtimes Near Lucas Cinemas Albertville
1-800-308-1977
Gopher Hockey Forum
Logisticare Transportation Provider Login
Rocky Bfb Asset
Fototour verlassener Fliegerhorst Schönwald [Lost Place Brandenburg]
Charlotte North Carolina Craigslist Pets
The Lives of Others - This American Life
Rubios Listens Com
Nc Scratch Off Left
Syracuse Deadline
Ny Trapping Forum
10-5 Study Guide And Intervention Tangents Answer Key
Craigslist Pinellas County Rentals
4156303136
Lacy Aaron Schmidt Where Is He Now
Autozone Cercano
How to Get Rid of Phlegm, Effective Tips and Home Remedies
10000 Divided By 5
Exclaimer | Office 365, Exchange & G Suite Email Software
North Bay Craigslist Jobs
Craigslistwesternmass
Montrose Colorado Sheriff's Department
Katie Hamden Of
Amazing Lash Bay Colony
Travelvids October 2022
Minecraft Skin Tynker
Unintelligible Message On A Warning Sign Crossword
Azpeople Self Service
Craigslist Antelope Valley General For Sale
Markella Magliola Obituary
Cnas Breadth Requirements
Latest Posts
Article information

Author: Fredrick Kertzmann

Last Updated:

Views: 6225

Rating: 4.6 / 5 (46 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Fredrick Kertzmann

Birthday: 2000-04-29

Address: Apt. 203 613 Huels Gateway, Ralphtown, LA 40204

Phone: +2135150832870

Job: Regional Design Producer

Hobby: Nordic skating, Lacemaking, Mountain biking, Rowing, Gardening, Water sports, role-playing games

Introduction: My name is Fredrick Kertzmann, I am a gleaming, encouraging, inexpensive, thankful, tender, quaint, precious person who loves writing and wants to share my knowledge and understanding with you.