Installing Mercury on Ubuntu

λ June 13, 2019
Tags: mercury

Having learned Prolog in 2012, and loved it ever since, and having used Haskell on and off for longer than I can remember (but not long enough to truly truly understand it yet) I once wrote a blog post about what my perfect programming language might be.

At the time I wrote it…

https://emacstheviking.blogspot.com/2016/05/the-ultimate-programming-language.html

I had no idea Mercury even existed! Today I decided to try it…

Installing it

The initial instructions are to download the latest stable release and then unpack it, change into the folder and do this:

./configure --enable-minimal-install
make
sudo make install

That almost worked for me first time except for a couple of missing packages that were required, this may or may not affect you as well. The missing packages were `and, and I installed them with:

sudo apt-get install flex
sudo apt-get install bison

These are, in case you don’t know, pretty standard tools for creating lexers and parsers if you are wanting to create your own computer language, for example.

Post-install setup and configuration

Once you have done the sudo make install bit, the console shows you some very helpful extra information which, depending upon your taste for an easy life, should probably be carried out as suggested!

Adding the Mercury bin to $PATH

Don’t forget to add /usr/local/mercury-14.01.1/bin to your PATH,

I use zsh so this was just a case of editing my ~/.zshrc and adding this line at the bottom of the file:

export PATH=$PATH:/usr/local/mercury-14.01.1/bin

Upgrading MANPATH & INFOPATH for reading pleasure

/usr/local/mercury-14.01.1/man to your MANPATH, and /usr/local/mercury-14.01.1/info to your INFOPATH,

…was as simple as adding this next to the previous item:

export MANPATH=$MANPATH:/usr/local/mercury-14.01.1/man
export INFOPATH=$INFOPATH:/usr/local/mercury-14.01.1/info

And some CGI black-magic

to copy deep_profiler/mdprof_cgi to /usr/lib/cgi-bin,

Not exactly sure what that’s all about but I did it anyway!

sudo mkdir /usr/lib/cgi-bin
sudo cp ./deep_profiler/mdprof_cgi /usr/lib/cgi-bin/.

Parallel building

Since building Mercury can take a long time, you may prefer to use multiple processors during the build process. Adding “PARALLEL=-jN” without the quotes to make’s command line will tell make to run N tasks at once. Substitute N with the number of processors in your system, or fewer if you want to use other processors for other tasks. For example:

make PARALLEL=-j4
sudo make PARALLEL=-j4 install

Of course, I didn’t see this little nuggest until after I’d installed it, right at the bottom of the page…I guess I still haven’t learned to read eveything before diving in after all these years! :)

Next time then!

Playing ball with Emacs

and to add the following lines to the `.emacs’ file in your home directory:

I mean who doesn’t use it for everything anyway? As instructed, I placed these lines into my ever swelling configuration:

(add-to-list 'load-path
        "/usr/local/mercury-14.01.1/lib/mercury/elisp")
(autoload 'mdb "gud" "Invoke the Mercury debugger" t)

In my next article in this series looking at Mercury, we’ll walk through how I fared following the mandatory “Hello World” application!

Comments