NOTE: This book is a work in progress.
Author: Zetian Lin (https://sebastian.graphics)
Project repository: https://github.com/bctnry/gentle-introduction-to-mercury
Latest version: Very Early Draft (October 2025)
Contact for sending comments and reviews:
zaaktin.lam {at} outlook [dot] com
You can always download the latest draft on GitHub:
https://github.com/bctnry/gentle-introduction-to-mercury/blob/master/main.pdf
Table of Contents
(NOTE: very early draft; subject to change.)
- Introduction
- What is Mercury?
- The state of things as of now
- Who’s this book for
- The tool we will be using
- More importantly... why?
- A First Taste of Mercury
- Prerequisite: logic programming
- Writing the program
- Programming in Mercury
- Trace Goals
- Using the standard library
- Basic Datatypes
- If-Then-Else
- Fundamental concepts
- Defining functions
- User-defined types
- Example 1: Interpreter of a small language
- Using multiple modules
- Higher-order programming
- Exception handling
- Advanced goals
- Working with other people's libraries
- Streams & IO
- Generating random numbers
- Threads
- Advanced Concepts & Usage
- Instantiatedness
- Modes
- Multiple solutions
- Definite Clause Grammar
- Typeclasses
- Existential Types
- Purity System
- Parsing With Definite Clause Grammar
- Foreign Language Interface
- Calling back and forth
- Working with the Java grade
- Working with the CSharp grade
- Debugging Mercury Programs