Simple Alarm Simulation - Mercury Typing CST Test
Loading…
Simple Alarm Simulation — Mercury Code
Simulates an alarm if threshold exceeded.
:- module alarm.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
main(!IO) :-
Temp = 80,
Thresh = 75,
io.write_string(if Temp > Thresh then "Alarm: Temperature Too High!\n" else "Temperature Normal\n", !IO).Mercury Language Guide
Mercury is a purely declarative logic programming language with strong typing, determinism analysis, and a focus on reliability and performance. It is designed for building large-scale, maintainable, and efficient logic programs while avoiding common pitfalls of traditional Prolog systems.
Primary Use Cases
- ▸Logic-based and symbolic programming
- ▸Constraint solving
- ▸Knowledge representation
- ▸Formal verification and theorem proving
- ▸Academic research and teaching
Notable Features
- ▸Purely declarative semantics
- ▸Strong, static type system
- ▸Mode and determinism checking
- ▸High-performance compiler
- ▸Separation of logic and control flow
Origin & Creator
Mercury was created in the mid-1990s by Zoltan Somogyi, Fergus Henderson, and Thomas Conway at the University of Melbourne, building on ideas from Prolog but with stricter type and mode systems.
Industrial Note
Mercury is used in academic research, formal verification, symbolic computation, and complex rule-based systems. While not mainstream, it is highly valued in areas requiring highly reliable logic programs.