[m-users.] Mercury operators explained
Piotr Trojanek
piotr.trojanek at gmail.com
Wed Feb 19 09:49:23 AEDT 2014
Thank you both for a detailed and prompt reply!
I am making my first steps with Mercury and perhaps I need a less
trial-and-error approach. However, I still can not find an explanation
of the "=\\=" operator. Is there any other reference/book/guide that I
should consult?
-- Piotr
On Wed, Feb 19, 2014 at 09:45:14AM +1100, Paul Bone wrote:
> On Tue, Feb 18, 2014 at 10:11:35PM +0000, Piotr Trojanek wrote:
> > Dear Mercury experts,
> >
> > please excuse me for a naive question, but where can I find
> > documentation of the Mercury operators?
> >
> > I was translating my code from SWI-Prolog and found that there is no
> > "=\=" operator in Mercury. There are many other built-in operators
> > listed in the Mercury Reference Manual, but they are not explained.
>
> There is no =\= module in Mercury. Arithmetic expressions are evaluated
> immediately, they do not create terms so you do not need "is" "=:=" or "=\="
> and so-on. The normal unification and comparison operators should be used.
>
> Operators are listed in the reference manual and explained in the library
> documentation. Operators such as "+" (like other predicates) can have
> definitions in different modules, for example the int module defines + as
> taking two "int"s and returning an "int", whereas the float module defines
> + as taking two "float"s and returning a "float". If your program imports
> both modules the compiler uses the types of variables in your program to
> work out which definition of + to use.
>
> Library reference:
> http://www.mercurylang.org/information/doc-release/mercury_library/index.html
>
> Some comparison operators are defined here:
> http://www.mercurylang.org/information/doc-release/mercury_library/builtin.html#builtin
>
> Goal operators such as conjunction, disjunction implication are defined in
> the reference manual:
> http://www.mercurylang.org/information/doc-release/mercury_ref/Goals.html#Goals
>
> Some symbols, although I wouldn't call them operators others may disagree,
> are used in declarations, for example the ---> used in type definitions are
> described throughout the reference manual.
>
> Also note that some symbols are used as both goal operators and symbols in
> declarations. For example implication <= is also used to describe typeclass
> constraints.
>
> I hope this helps.
>
>
> --
> Paul Bone
--
Piotr Trojanek
More information about the users
mailing list