[m-dev.] EDCGs and Higher Order Programming

Ralph Becket rbeck at microsoft.com
Fri Jan 28 04:04:03 AEDT 2000


> Well, you can do a little better by abstracting out the conversion
> function:
> 
> 	:- func io2p((pred)+hidden(changed(io))) = 
> pred(io__state, io__state).
> 	:- mode io2p(in(pred)) = out(pred(di, uo) is det).
> 	io2p(P) = (pred(IO0::di, IO::uo) is det :-
>  			(io is changed(IO0, IO) -->> P)).
> 
> Then you can write `write_strings' as
> 
> 	write_strings(Strs) -->>
> 		list__foldl(io2p(io__write_string), Strs, $io, $=io).
> 
> [...]
> 
> but the ", $io, $=io" notation is sufficiently concise that there is
> no need.

Putting in `$io, $=io' seems to fly in the face of the EDCG style.
I'd rather see something like

write_strings(Strs) -->>
	list__foldl(io__write_string, Strs) + hidden(changes(io)).

The primary virtue of this is that it looks absolutely nothing like
Perl.  Admittedly, we might have trouble overloading +/2 in this
way, but we could always introduce infix @ or somesuch.

Ralph
--------------------------------------------------------------------------
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