caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Labels and polymorphism
@ 2007-03-08 18:31 Nathaniel Gray
  2007-03-08 19:14 ` [Caml-list] " Eric Cooper
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Nathaniel Gray @ 2007-03-08 18:31 UTC (permalink / raw)
  To: OCaml

I was recently bemoaning the way that folds (especially nested folds)
using longish anonymous functions become very hard to read, since the
argument order is optimized for greatest opportunity for partial
application rather than readability.  This led me to think about using
ListLabels in my code, but then I hit this bit of documentation:

"""
As an exception to the above parameter matching rules, if an
application is total, labels may be omitted. In practice, most
applications are total, so that labels can be omitted in applications.
...
But beware that functions like ListLabels.fold_left whose result type
is a type variable will never be considered as totally applied.
"""

Wha??  I'm trying to wrap my head around this but I'm just totally
confused.  I thought that playing around in the interpreter would
help, but it just left me more confused:

# let f ~x = x;;
val f : x:'a -> 'a = <fun>
# f ~x:1;;
- : int = 1
# f 1;;
- : x:(int -> 'a) -> 'a = <fun>
# let y = f 1;;
val y : x:(int -> 'a) -> 'a = <fun>
# y (fun x -> x+1);;
- : x:(int -> (int -> int) -> 'a) -> 'a = <fun>

Can somebody make sense of this for me?  Is there a paper somewhere on
labels in ocaml that I should read?

Thanks,
-n8

-- 
>>>-- Nathaniel Gray -- Caltech Computer Science ------>
>>>-- Mojave Project -- http://mojave.cs.caltech.edu -->


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-03-20  0:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-08 18:31 Labels and polymorphism Nathaniel Gray
2007-03-08 19:14 ` [Caml-list] " Eric Cooper
2007-03-08 19:40 ` Roland Zumkeller
2007-03-08 23:42   ` Nathaniel Gray
2007-03-19  1:15     ` Jacques Garrigue
2007-03-19 23:53       ` Nathaniel Gray
2007-03-20  0:51         ` Jacques Garrigue
2007-03-08 23:30 ` skaller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).