Sign inSign up

100hellos/mercury

By 100hellos

•Updated 4 months ago

"Hello World!" Written in mercury

Image
0

3.6K

100hellos/mercury repository overview

⁠Hello World! From mercury.

Language page⁠ — context, influences, and learning notes on the 100hellos site.

Source on GitHub⁠ (100hellos/mercury)

⁠Trying it

docker run --rm --platform="linux/amd64" 100hellos/mercury:latest

⁠Modifying it

Read the repo README⁠, or fork the project⁠ and customize it.

For an interactive shell:

docker run --rm --platform="linux/amd64" --entrypoint="" -it 100hellos/mercury:latest zsh

⁠Mercury

Mercury is a pure logic programming language that combines the power of Prolog with static typing and functional programming features. It was designed at the University of Melbourne for building large, reliable, and efficient applications.

⁠About Mercury

Mercury is known for its:

  • Strong static typing: Type errors are caught at compile time
  • Mode system: Ensures variables are used correctly
  • Determinism system: Specifies whether predicates succeed, fail, or produce multiple solutions
  • Functional and logic programming: Supports both paradigms seamlessly
  • High performance: Compiles to efficient C code

⁠Features

Mercury combines the expressiveness of logic programming with the safety of strong typing. The language uses a sophisticated type, mode, and determinism system to ensure program correctness at compile time.

The Mercury compiler generates efficient C code and provides excellent error messages, making it suitable for large-scale software development.

⁠Hello World Explained

:- module hello_world.

:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.

:- implementation.
main(!IO) :-
    io.write_string("Hello World!", !IO).
  • :- module hello_world. - Declares the module name
  • :- interface. - Begins the public interface section
  • :- import_module io. - Imports the I/O module
  • :- pred main(io::di, io::uo) is det. - Declares main as a deterministic predicate
  • main(!IO) :- - Uses state variables for I/O threading
  • io.write_string("Hello World!", !IO) - Outputs the string

⁠Learn More

Tag summary

Content type

Image

Digest

sha256:cd83f828d…

Size

121.5 MB

Last updated

4 months ago

docker pull 100hellos/mercury