[mercury-users] full and empty lists

David Overton dmo at cs.mu.OZ.AU
Mon Jan 14 12:03:06 AEDT 2002


On Mon, Jan 14, 2002 at 11:20:15AM +1100, Ralph Becket wrote:
> Dave Slutzkin, Sunday, 13 January 2002:
> > Hi all.
> > 
> > :- mode ne_tl_io == ground >> non_empty_list.
> > :- mode ne_tl_in == non_empty_list >> non_empty_list.
> 
> You can use the built-in parametric modes in/1 and out/1 here to say the
> same thing:
> 
> :- mode ne_tl_io == out(non_empty_list).
> :- mode ne_tl_in == in(non_empty_list).
> 
> Why did you pick the name "ne_tl_io"?
>                                  ^^
> Surely you mean "ne_tl_out"?

Ralph, I think you've misread his code.  The mode ne_tl_io is 
`ground >> non_empty_list', not `free >> non_empty_list' so using
`out/1' is incorrect.

> 
> > :- func empty_timeline = (timeline::out) is det.
> > :- pred full_timeline(timeline::ne_tl_io) is semidet.
> > 
> > empty_timeline = [].
> > full_timeline([_|_]).
> 
> The mode for full_timeline/1 is wrong.

Only using your definition of ne_tl_io :-)

> 
> If it is intended to construct a partially instantiated list then you
> need
> 
> :- mode ne_tl_skel_out == out(bound([free | free])).
> 
> :- mode full_timeline(ne_tl_skel_out) is det.
> 
> However, I'm not sure that the current mode system will be happy with
> the use of partially instantiated data (Dave?)

No, they aren't really usable.



David
-- 
David Overton      Department of Computer Science & Software Engineering
PhD Student        The University of Melbourne, Victoria 3010, Australia
+61 3 8344 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