Top 1K Features Creators Events Podcasts Books Extensions Interviews Blog Explorer CSV

Mercury

< >

Mercury is an open source programming language created in 1995 by Zoltan Somogyi.

#383on PLDB 29Years Old 715Repos
Homepage · Wikipedia · Subreddit · Docs

Mercury is a functional logic programming language made for real-world uses. The first version was developed at the University of Melbourne, Computer Science department, by Fergus Henderson, Thomas Conway, and Zoltan Somogyi, under Somogyi's supervision, and released on April 8, 1995. Mercury is a purely declarative logic programming language. Read more on Wikipedia...


Example from hello-world:
:- module hello. :- interface. :- import_module io. :- pred main(io::di, io::uo) is det. :- implementation. main(!IO) :- io.write_string("Hello World\n", !IO).
Example from Linguist:
% "Hello World" in Mercury. % This source file is hereby placed in the public domain. -fjh (the author). :- module hello. :- interface. :- import_module io. :- pred main(io::di, io::uo) is det. :- implementation. main(!IO) :- io.write_string("Hello, world\n", !IO).
Example from Wikipedia:
:- module fib. :- interface. :- import_module io. :- pred main(io::di, io::uo) is det. :- implementation. :- import_module int. :- func fib(int) = int. fib(N) = (if N =< 2 then 1 else fib(N - 1) + fib(N - 2)). main(!IO) :- io.write_string("fib(10) = ", !IO), io.write_int(fib(10), !IO), io.nl(!IO). % Could instead use io.format("fib(10) = %d\n", [i(fib(10))], !IO).

Language features

Feature Supported Example Token
Strings ✓ "Hello world" "
Print() Debugging ✓ io.write_string
Comments ✓ % A comment
Line Comments ✓ % A comment %
Semantic Indentation X

- Build the next great programming language · Add · Issues · About · Search · Keywords · Livestreams · Labs · Resources · Acknowledgements

Built with Scroll v154.3.0