[mercury-users] A source-to-source translator

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Feb 1 12:38:11 AEDT 2003

On 31-Jan-2003, Bill McEnaney <bill at rkirkpat.net> wrote:
> Does anyone know of a program that translates Prolog to Mercury?  Thanks
> so much.

As far as I know, there is no such program.

Translating Prolog to Mercury can sometimes be a quite difficult task.
It depends a lot on the style of the Prolog program that you are trying
to convert.

One thing that can sometimes help is to use the Mercury compiler's
`--infer-all' option.  That can help infer type, mode, and determinism
declarations for predicates and functions.  However, the following parts
of the transformation still need to be done manually:

	- providing definitions of data types

	- adding Mercury module system declarations (e.g. `:- interface',
	  `:- implementation', and `:- import_module'), or converting
	  Prolog module system declarations to Mercury

	- converting code that uses cut to instead use if-then-else
	  where appropriate, and removing other uses of cut

	- converting calls to builtin Prolog procedures to instead
	  call the corresponding procedures in the Mercury standard

	- converting impure Prolog code to pass around a
	  "state-of-the-world" argument (normally this would be
	  done using DCG or state variable syntax).

	- rewriting Prolog code that relies on dynamic modes

(There might also be some other issues that I don't recall right now.)

The Mercury standard library provides a module `prolog' which is
intended to make it easier to convert Prolog programs to Mercury.

For more details on some of these issues, see the "Prolog to Mercury
transition guide" which is on our web site and also included in the
Mercury distribution.

Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe

More information about the users mailing list