[mercury-users] list functor style functions

David Overton dmo at cat.cs.mu.OZ.AU
Mon Nov 15 13:56:33 AEDT 1999


On Fri, 12 Nov, 1999 at 06:28:44PM EST, Peter Schachte wrote:
> 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).
> 

Actually, the way I've implemented it, using extras/lazy_evaluation/lazy.m, 
you _can_ backtrack over the deconstruction function, due to the
operational semantics of force/1 which will cause the closure to
be evaluated only once.


David
-- 
David Overton       Department of Computer Science & Software Engineering
PhD Student         The University of Melbourne, Australia
+61 3 9344 9159     http://www.cs.mu.oz.au/~dmo
--------------------------------------------------------------------------
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