[mercury-users] list functor style functions

Peter Schachte schachte at cs.mu.OZ.AU
Fri Nov 12 18:28:44 AEDT 1999


On Fri, Nov 12, 1999 at 04:19:24PM +1100, David Overton wrote:
> You can do some neat syntactic tricks by overloading []/0 and '.'/2 as
> well.  For example, I once overloaded these functions to work with
> Fergus's lazy_list module and was then able to to use DCG syntax for
> parsing lazy lists.  Adding a lazy read predicate (ala Haskell's readFile)
> meant I could parse input without reading it all into a list first.

This is exactly the sort of thing I had in mind, though in this case I
think you want something like a destructive_input_sequence type class,
which is like an input_sequence, except that you can't backtrack over
deconstructions (ie, the deconstruction function has a [uo|uo] = di
mode, instead of [out|out] = in).


-- 
Peter Schachte                     All truth goes through three stages.
mailto:schachte at cs.mu.OZ.AU        First it is ridiculed. Then it is
http://www.cs.mu.oz.au/~schachte/  violently opposed. Finally, it is
PGP: finger schachte at 128.250.37.3  accepted as self-evident.
--------------------------------------------------------------------------
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