[m-dev.] Suggested interface for sequence types in lib-v2

Ralph Becket rbeck at microsoft.com
Mon Oct 23 21:04:08 AEDT 2000


>From Fergus Henderson on 20/10/2000 16:25:25
> 
> I think `all_but_last' would be a much clearer name.

Righto.

> OK, I see.  Yes, for historical reasons `member' goes against our
> usual style guidelines about argument ordering.
> 
> The name `project_member' doesn't mean much to me.
> I think `has_member' or perhaps `contains_member' would be a better
> name.  It would work nicely with infix syntax:
> 
> 	List `has_member` Elem

Hmm.  `{has,contains}_member' both sound rather like tests to me
rather than predicates that non-deterministically enumerate
members.  How about `choose_member' or just `choose'?

> Only one of member/2 and project_member/2 (or has_member/2)
> should be a class method.  The other should just be an
> ordinary procedure with a class constraint on its type.
> This ensures that the relationship between the meaning
> of these two always remains unchanged.

Agreed.  However, until we get the typeclass issues sorted out we'll
have to require library writers to supply both predicates.

> > 	rev_append(S1, S2) = reverse(S1) ++ S2
> 
> OK.  The original documentation has a lot of room for improvement ;-)

You're not wrong...

> > condense_map/2 is there to avoid construction of an intermediate
> > sequence.
> 
> I don't think this is likely to be useful enough to warrant inclusion.
> I'd leave it out for now.  We can always add it later if it turns
> out to be widely needed.

Okay.

> > Okay.  The convention I was using was that operation foo would be
> > det while semidet_foo would be semidet.  In this case it's not
> > clear whether the proper functionality is to delete the first
> > x if one is present, otherwise do nothing.  Hmmm...
> 
> In most situations where you want that functionality ("otherwise do
> nothing"), `delete_all' will do.  So I think `delete_first_det' should
> call error/1 if the element isn't present.

At the moment I have `delete_first/2' which raises an error if no such
member is present and `delete_first_if_any/2' which defaults to the 
identity function if the argument is not a member.

I'll leave this as-is until the debate below is decided...

> > I think that is true for predicates, but that the reverse should
> > be the case for functions.  After all, one usually expects a function
> > to be deterministic.
> 
> Hmm, good point.
> 
> > I'm prepared to be converted on this one...
> > anybody else have any strong feelings?
> 
> I'd be very interested in other people's views on this one.

Answer came there none.

Thanks for the feedback; I'll re-post the updated draft.

--
Ralph Becket      |      MSR Cambridge      |      rbeck at microsoft.com 

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