caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Nathaniel Gray <n8gray@gmail.com>
Cc: OCaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Labels and polymorphism
Date: Fri, 09 Mar 2007 10:30:28 +1100	[thread overview]
Message-ID: <1173396628.6613.33.camel@rosella.wigram> (raw)
In-Reply-To: <aee06c9e0703081031o5b5c2a9fy46d7b37e4999a897@mail.gmail.com>

On Thu, 2007-03-08 at 10:31 -0800, Nathaniel Gray wrote:
> 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:

It's simple:

# let id x = x;;
val id : 'a -> 'a = <fun>
# id 1;;
- : int = 1


id has arity 1 and is fully applied when it has one argument
right? 

# let f x = x * x;;
val f : int -> int = <fun>

# id f 2;;
- : int = 4

WOOPS! Here id has TWO arguments ...

So the arity of a function returning a type variable is
indeterminate, so you cannot tell if it is fully applied or not.

Hence the caveat.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


      parent reply	other threads:[~2007-03-08 23:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-08 18:31 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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1173396628.6613.33.camel@rosella.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=n8gray@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).