[m-users.] DCG-s in Mercury

Sean Charles (emacstheviking) objitsu at gmail.com
Sat Apr 24 19:33:31 AEST 2021


Hi,

I am but a mere mortal, not formally schooled in logic and its terminology. Despite repeated googling, watching and reading my entire set of Prolog books, the terms ‘existential’ and ‘universal’ barely mean anything to me and now I have two sets of DCG rules to port from SWI Prolog and I just don’t know where to start. At the root ?

Is there anywhere to be found a short, concise example of how to create a DCG rule, just so I can see some examples of the mode declarations, mine are not going to be used as generators, just as a lever and a parser/AST builder. I use phrase_from_file/3 in SWI Prolog, and the debugger means I can step through any rules that aren’t doing what I think. So far in mercury I have not even worked out how to start calling the head rule, if you call it that.

I’ve built and use an ROTD from sources:

    ➜  mcnew mmc —version
    Mercury Compiler, version rotd-2021-04-15, on x86_64-apple-darwin19.6.0
    Copyright (C) 1993-2012 The University of Melbourne
    Copyright (C) 2013-2021 The Mercury team


I continue reading the Mercury language reference guide in hope of more Eureka moments, I really think Mercury is the one language I could spend the rest of my days being happy with, it has the good bits from Prolog and Haskell and much more but as a non-degree/CS person, as a completely self-taught developer going back 35 years, the documentation is somewhat lacking in sympathy for newcomers, not its fault to be sure but Mercury is not mainstream and so there is not an awful lot of example stuff out there and what I have found suffers from the same problem: I am not smart enough to understand the awesomely flowery language as it leaves me feeling cold and glazed over and totally disillusioned at times. Again, as they say, “It’s not you, it’s me”.

So. Thanks for Mercury chaps, a brilliant piece of work that the world probably won’t ever fully appreciate, but I do.
It’s just a shame I can’t use it yet! 
:)

All the best,
Sean.




More information about the users mailing list