Learn MERCURY with Real Code Examples
Updated Nov 20, 2025
Installation Setup
Download Mercury compiler for your OS
Install compiler and set PATH environment variable
Verify installation with 'mmc --version'
Create a Mercury source file (.m)
Compile using 'mmc file.m' and run with executable
Environment Setup
Download Mercury compiler
Install compiler and set PATH
Test installation with sample program
Organize source files and modules
Compile and run test predicates
Config Files
Source files (.m)
Interface files (.m)
Makefile or build scripts
Documentation files
Test modules
Cli Commands
mmc --make program.m
mmc --run program
mmc --target=c program.m
mercury --help
mercury --version
Internationalization
Supports Unicode in string terms
Localization handled via program logic
No built-in i18n system
Integration via external libraries possible
Useful for multi-language logic programs
Accessibility
Command-line interface
Mercury compiler available for Linux, macOS, Windows
Documentation and tutorials accessible online
Active research community
IDE support via editors like Emacs, Vim, VSCode
Ui Styling
Mercury does not provide GUI or styling
Typically used for backend logic or symbolic computation
Output via console or external interface
Integration possible via FFI for GUI
Focus on logic correctness over presentation
State Management
Logic state represented by predicates
Input/output managed via modes
Pure declarative approach ensures predictable state
Modules encapsulate local state
Side effects isolated in deterministic code paths
Data Management
Strongly typed terms and structures
Input/output specified via modes
Recursion for data traversal
No mutable state; pure declarative semantics
Use of lists, sets, and user-defined types