[m-dev.] user-defined operators

Peter Ross petdr at cs.mu.OZ.AU
Fri Jul 9 11:29:15 AEST 1999


On 08-Jul-1999, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 08-Jul-1999, Ralph Becket <rwab1 at cam.sri.com> wrote:
> > What's the status of setting up your own operators?  On the one hand
> > I'm against it seeing how the facility gets abused by novice Prolog
> > programmers; on the other it seems genuinely useful for such functions
> > as the above and for e.g. coding in the monadic style.
> 
> I agree that it is genuinely useful.
> 
> However, it is non-trivial to implement, if you want to do it properly.
> The problem is the way in which it interacts with the module system.
> Supporting user-defined operators within a single module would not be
> too hard, but really you'd like to be able to declare operators in
> the interface section of a module and have them exported to other
> modules.  Unfortunately allowing that makes things much trickier...
> 

Would the haskell approach taken from the haskell-98 report be an
acceptable compromise?

Alphanumeric operators are formed by enclosing an identifier between
grave accents (backquotes). Any variable or constructor may
be used as an operator in this way. If fun is an identifier (either
variable or constructor), then an expression of the form fun x y is
equivalent to x `fun`y. If no fixity declaration is given for `fun` then
it defaults to highest precedence and left associativity

http::/www.cs.mu.oz.au/~fjh/haskell/haskell98-report-html/exps.html#sect3.2
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list