The Mercury Language Reference Manual
Fergus Henderson
Thomas Conway
Zoltan Somogyi
David Jeffery
Peter Schachte
Simon Taylor
Chris Speirs
Introduction
Syntax
Syntax overview
Tokens
Terms
Items
Declarations
Facts
Rules
Goals
DCG-rules
DCG-goals
Data-terms
Data-functors
Conditional expressions
Lambda expressions
Higher-order function applications
Implicit quantification
Elimination of double negation
Types
Modes
Unique modes
Destructive update
Backtrackable destructive update
Limitations of the current implementation
Determinism
Determinism categories
Determinism checking and inference
Replacing compile-time checking with run-time checking
Interfacing nondeterministic code with the real world
Committed choice nondeterminism
User-defined equality predicates
Higher-order programming
Creating higher-order terms
Calling higher-order terms
Higher-order modes
Modules
The module system
An example module.
Sub-modules
Nested sub-modules
Separate sub-modules
Visibility rules
Implementation bugs and limitations
Type classes
Typeclass declarations
Instance declarations
Abstract instance declarations
Type class constraints on predicates and functions
Type class constraints on type class declarations
Type class constraints on instance declarations
Existential types
Existentially typed predicates and functions
Syntax for explicit type qualifiers
Semantics of type qualifiers
Examples of correct code using type quantifiers
Examples of incorrect code using type quantifiers
Existential class constraints
Existentially typed data types
Some idioms using existentially quantified types
Known bugs in the current implementation
Semantics
C interface
Calling C code from Mercury
pragma import
pragma c_code
Nondet pragma c_code
C code attributes
Purity and side effects
Including C headers
Including C code
Calling Mercury code from C
Linking with C object files
Passing data to and from C
Using C pointers
Memory management
Trailing
Choice points
Value trailing
Function trailing
Delayed goals and floundering
Avoiding redundant trailing
Impurity declarations
Choosing the right level of purity
Semantics
Declaring predicate impurity
Marking a call as impure
Promising that a predicate is pure
An example using impurity
Pragmas
Inlining
Type specialization
Syntax and semantics of type specialization pragmas
When to use type specialization
Implementation specific details
Obsolescence
Source file name
Implementation-dependent extensions
Fact tables
Tabled evaluation
Termination analysis
Bibliography
[1]
[2]
[3]
[4]
[5]
This document was generated using the
texi2html
translator version 1.31.