[mercury-users] Colon as a type constructor?

Robert Bossy bossy at ccr.jussieu.fr
Tue May 15 01:12:11 AEST 2001


Ondrej Bojar a écrit :
> 
> Hi.
> 
> I'd like to write pairs with colons and not with dashes :-)
> But colonpair won't work:
> 
> :- type colonpair(A, B) ---> A : B.
> 
> Error: invalid RHS of type definition: A : B.

The colon is the module qualifier.
Since curly braces are used to escape ';' and curly braces in type definitions, I was about to suggest:

:- type colonpair(A, B) ---> {A : B}.


But then again it doesn't work. I can't tell why.


> P.S.: Thanks a lot for debugprinting - impure io. I love the chance to
> define :-pred dbgprint(string::in) is det. Use it anywhere I with and when
> done, just replace the definition with :- dbgprint(Anything) :- true.

Don't forget to declare it impure:

:- impure pred dbgprint(string::in) is det.

Because if you don't, you can get your messages in a confusing order. The compiler may reorder goals in a conjunction or in a disjunction. It happened.
The 'impure' declaration tells the compiler (and the programmer) there's a "clandestine" side effect so it doesn't reorder.

-- 
Robert Bossy
      bossy at ccr.jussieu.fr
.
--------------------------------------------------------------------------
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