[m-users.] To learn Mercury

Charles Shuller charles.shuller at gmail.com
Mon Mar 20 00:08:29 AEDT 2017

I was hoping someone might have a better answer than I did, and hopefully
smarter people will promptly issue any needed corrections :)

There _is_ a tutorial here:

I found the first few examples to be very useful, but then it jumped right
into a decryption thing, which was counter productive to me.    This has
generally been a problem with functional language books in my experience

Mercury happens to be nearly exactly like Prologue though, and I found the
following book to be very useful to me as well:

There is a lot of really brilliant work that makes Mercury totally
awesome.  You should ignore all of that while learning the basic
language.   In particular, skipping DCG's and different language targets is
completely safe, but you still have to know that "!IO" is really compiler
magic for two parameters when looking up function calls.

Skip anything about Lambda's and Higher Order Programming until you've got
quite a lot of XP, they are cool and important, but if you aren't
comfortable with functions and predicates, they'll totally just get in the

Skip trying to define your own types for now, stick to programs that use
the built in ones.

You need to know that Variables NEVER get reassigned to (remember that !IO
is compiler magic) and that this is a very good thing, though it'll
probably drive you mad if you think your wasting a bunch of RAM with all
the variables (I've not ever seen this cause any noticeable memory
consumption, and I've stopped reassigning variables in all my other code as
well whenever possible).

Finally, there is a very subtle difference between predicates and
functions.   For me, I just stuck with predicates for a long time and
ignored functions.  I think it's probably a pretty good route to go, since
Mercury tends to take up a lot of space horizontally.

If you know nothing at all about programing in general, Mercury may not be
the best language to learn in.   It's got a bit of "magic" you need to know
about up front (the !IO stuff for instance) and you'll need to know the
difference between a modules public interface and it's implementation.
There is also a lot of "chatter" that isn't needed for very simple programs
that gets in the way of learning.

Personally, I've found Python to be the easiest language for a beginner to
learn in, just don't get caught up in the idea that it's the right solution
to every problem.   In my experience Python has been very bad at any
program of scale.   But beginners need to write lots of small programs
anyway.   Once you get variables, and functions well understood in Python,
they'll make a lot more sense in mercury (though they aren't quite the same
thing they are based on the same underlying concepts).

Good Luck!


On Sat, Mar 18, 2017 at 10:20 AM, Echedey López Romero <elr at openmailbox.org>

> Hi users.
> How can i to learn Mercury lang?
> I didn't find any complete documentation or tutorial for people that
> want to learn from scratch.
> --
> Regards,
> Echedey López Romero
> _______________________________________________
> users mailing list
> users at lists.mercurylang.org
> https://lists.mercurylang.org/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20170319/353acf15/attachment.html>

More information about the users mailing list