[Ur] Functional infix operators ?

Timothy Beyer beyert at fastmail.net
Thu Feb 19 21:46:40 EST 2015


At Thu, 19 Feb 2015 18:34:49 +0000 (UTC),
Gabriel Riba wrote:
> 
> Adam Chlipala <adamc <at> csail.mit.edu> writes:
> 
> > 
> > OK, I see.  By "functional," you meant "related to function application, 
> > composition, etc.", not a general mechanism for introducing new infix 
> > operators.
> > 
> > If you (or anyone else) want to experiment with tweaking src/urweb.grm 
> > to add some new operators, I'll be happy to accept a patch embodying 
> > tasteful choices. :)  (May also require adding to lib/ur/top.ur[s] new 
> > definitions of conventionally named functions, to which the new 
> > operators desugar.)
> > 
> 
> Hello!
> 
> I've worked out a solution for the function application and composition
> operators, after revising the mlton manuals for ml-lex and ml-yacc, and it
> works.
> 
> I need your opinion to ensure if it is complete.
> 
> The operators in this trial are
> 
> (<|) : forward application (right associative), named FWDAPP in .lex and .grm
> (|>) : reverse application (left associative), named REVAPP
> (<<<) : right-to-left composition (right associative) (equivalent to ML's
> (o)), named COMPOSE
> (>>>) : left-to-right composition (right associative), named ANDTHEN

I can't speak for Adam, but I've wanted infix apply and compose operators in Ur/Web for a while, so I'm looking forward to trying this patch.

If Ur/Web ever gains pattern matching on a function level (eg. without requiring an extra case statement), plus pattern matching extensions such as OR patterns, and more concise operators for sources, then it would be absolute bliss for me, even though what I suggest is quite a lot of syntactic sugar.

Regards,
Tim



More information about the Ur mailing list