[mercury-users] Colon as a type constructor?

Fergus Henderson fjh at cs.mu.OZ.AU
Tue May 15 02:35:30 AEST 2001

On 14-May-2001, Ondrej Bojar <oboj7042 at ss1000.ms.mff.cuni.cz> wrote:
> And what does :: in type definitions mean?

It can be read as "has type".

> One of my error messages says:
> dagorunify.m:060: In clause for predicate `dagorunify:nunify/3':
> dagorunify.m:060:   in argument 1 of clause head:
> dagorunify.m:060:   type error in unification of variable `HeadVar__1'
> dagorunify.m:060:   and functor `orlist/1'.
> dagorunify.m:060:   variable `HeadVar__1' has type `(list:list((dagorunify:dagpair)))',
> dagorunify.m:060:   functor `orlist/1' has type
> dagorunify.m:060:   `orlist((list:list(A))) :: (dagorunify:orlist_t(A))'.

This means that argument 1 (`HeadVar__1') has type `list(dagpair)',
while the functor orlist/1 takes an argument of type `list(A)',
and returns a result of type `orlist_t(A)'.

You're trying to unify
the first argument with a term `orlist(...)', but since the
first argument has type `list(dagpair), and the term `orlist(...)'
has type `orlist(A)', and `list(dagpair)' does not match `orlist(A)',
you get a type error.

> ----
> Line 60:
>  nunify(orlist(Dags1), orlist(Dags2), orlist(Res)) :-
> And the typedefs:
> :- type dag == list(dagpair).
> :- type dagorlist == orlist_t(dag).
> :- type orlist_t(A) ---> orlist(list(A)).
> ...

Probably you have declared

	:- pred nunify(list(dagpair), ...).

but it should be

	:- pred nunify(or_list_t(...), ...).

Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  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