[containers-users] [poll] use more labels?

Malcolm Matalka mmatalka at gmail.com
Sun Sep 20 22:05:05 BST 2015


Simon Cruanes <simon.cruanes.2007 at m4x.org> writes:

> Hello,
>
> Some users want functions to have labels when it makes sense (à la
> Core), and I kind of like the idea in many cases (especially to label
> functions with ~f).
>
> Apparently, a function declared with labels can be called without them
> if arguments are in the right order (at the possible price of a
> warning). That means that it should be possible to add labels in many
> modules *without* breaking compatibility.
>
> What do you think? Are there strong oppositions to this idea?
>
> The next release of containers is approaching (in a few weeks max, I
> think), but this can wait if there is no consensus.
>
> Cheers!

As one of those users, I support this.  However, a few specifics to
consider.  After some more testing it looks like it would break
backwards compatibility in some ways.  Specifically:

 # let f ~x ~y = x + y;;
 val f : x:int -> y:int -> int = <fun>
 utop # f 2;;
 Error: The function applied to this argument has type x:int -> y:int ->
 int
 This argument cannot be applied without label

This is obviously problematic if anyone is partially applying.

The other issue is that there should be some convention for what should
get a label and what shouldn't.  Specifically to handle this case:

utop # f ~x:2 3;;
Error: The function applied to this argument has type y:int -> int
This argument cannot be applied without label

This matters because I often structure code like:

list |> List.filter ~f:filter |> List.map ~f:map ....

The convention I have been following in my code is that the 't' that the
modules operates on is never labeled.


More information about the Containers-users mailing list