[mercury-users] polymorphism

Tomas By T.By at dcs.shef.ac.uk
Fri Sep 26 09:24:55 AEST 1997


"Fergus Henderson" <fjh at cs.mu.oz.au> wrote:
> Tomas By, you wrote:
> > In general, if I have a procedure with several modes, eg:
> > [...]
> > but I can't use the same code for both modes, how do I write
> > the "top-level"?
> The way to do this is to pass a argument specifying the direction:
> [...]

Hmm. Is there any reason to do it that way rather than have two
different procedures?:

   :- pred stream_to_tree(stream(T),tree(T)).
   :- mode stream_to_tree(in,out).

   :- pred tree_to_stream(tree(T),stream(T)).
   :- mode tree_to_stream(in,out).

/Tomas




More information about the users mailing list