Elm Exactly

A Standard Definition of Elm?

Draft version 0.4
Rupert Smith

A formal definition of the Elm language: its grammar, its static semantics (which programs are legal, and their types) and its dynamic semantics (what they do), as numbered inference rules in the manner of The Definition of Standard ML. Every rule has its own page and a permanent address, so that it can be cited, linked to and discussed.

Draft. This edition is a draft for review. Many of its rulings are provisional, and rule numbers may change between editions; a rule's address, which uses its name, does not.

Mechanised. The static and dynamic semantics are encoded in the proof assistant Lean 4, one constructor per rule, with a type inference proved sound and principal and an evaluator proved sound and complete. Lean proves which of the suite's test programs are legal, and runs those that compile to prove their checks. See the Lean proofs, each with a page of its own.

Take part. Each of those pages, and each chapter, has a Discussions section: start a discussion of the item on GitHub with its Discuss link, and the discussion is shown on the page. See all the discussions, or the Standard category of the repository's GitHub Discussions.

Contents

  1. Preface
    1. Standard Elm
    2. Language Definition
    3. This Definition
    4. How this Definition was Produced
    5. Acknowledgements
  2. 1Introduction
  3. 2Syntax of the Core
    1. 2.1Reserved Words
    2. 2.2Special Constants
    3. 2.3Comments
    4. 2.4Identifiers
    5. 2.5Lexical Analysis
    6. 2.6Layout
    7. 2.7Infixed Operators
    8. 2.8Derived Forms
    9. 2.9Grammar
    10. 2.10Syntactic Restrictions
  4. 3Syntax of Modules
    1. 3.1Reserved Words
    2. 3.2Identifiers
    3. 3.3Infixed Operators
    4. 3.4Layout
    5. 3.5Grammar for Modules
    6. 3.6Default Imports
    7. 3.7Syntactic Restrictions
  5. 4Static Semantics for the Corerules 1–45
    1. 4.1Simple Objects
    2. 4.2Compound Objects
    3. 4.3Projection, Injection and Modification
    4. 4.4Classes and Admissible Types
    5. 4.5Types and Type Functions
    6. 4.6Type Schemes
    7. 4.7Scope of Explicit Type Variables
    8. 4.8Closure
    9. 4.9Inference Rules
    10. 4.10Principal Derivations
    11. 4.11Further Restrictions
  6. 5Static Semantics for Modulesrules 46–64
    1. 5.1Semantic Objects
    2. 5.2Interfaces
    3. 5.3Provider Maps
    4. 5.4Port Types
    5. 5.5Inference Rules
    6. 5.6Principal Derivations
    7. 5.7Further Restrictions
  7. 6Dynamic Semantics for the Corerules 65–112
    1. 6.1Reduced Syntax
    2. 6.2Number Specialisation
    3. 6.3Simple Objects
    4. 6.4Compound Objects
    5. 6.5Basic Values
    6. 6.6Function Closures
    7. 6.7Inference Rules
  8. 7Dynamic Semantics for Modulesrules 113–132
    1. 7.1Reduced Syntax
    2. 7.2Compound Objects
    3. 7.3Merging Environments
    4. 7.4Record Constructors
    5. 7.5Top-level Value Groups
    6. 7.6Inference Rules
  9. 8Tasks, Commands, Subscriptions and Portsrules 133–171
    1. 8.1Simple Objects
    2. 8.2Compound Objects
    3. 8.3Inference Rules
    4. 8.4Tasks
    5. 8.5Commands and Subscriptions
    6. 8.6The Effect Values of the Basis
    7. 8.7Ports
    8. 8.8Messages
  10. 9Programsrules 172–194
    1. 9.1Syntax of Programs
    2. 9.2Elaboration of Programs
    3. 9.3Evaluation of Programs
    4. 9.4Execution
    5. 9.5Observable Behaviour
    6. 9.6Views and Other Programs

Appendices

  1. ADerived Forms
    1. A.1Grouping the Definitions of a Let
    2. A.2Grouping the Declarations of a Module
  2. BFull Grammar
  3. CThe Initial Static Basis
    1. C.1Type Names
    2. C.2The Module Environment
    3. C.3Basics
    4. C.4Further Data Types
    5. C.5Debugging, Programs and Effects
  4. DThe Initial Dynamic Basis
    1. D.1Special Values
    2. D.2The Value Environments
    3. D.3Values Written in Elm
    4. D.4The Function APPLY
  5. EImplementation-Dependent Details
    1. E.1The Int Range and Normalisation
    2. E.2Characters and Strings
    3. E.3Floating-Point Operations
    4. E.4Equality
    5. E.5Bitwise Operations and String Conversion
    6. E.6Evaluation Order and Debug
    7. E.7Resource Limits
    8. E.8Platform and Ports
    9. E.9Extensions of eco
    10. E.10Known Divergences
  6. FElm and Standard ML
    1. F.1What Is the Same
    2. F.2Differences by Construct

A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.