caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Tom Primožič" <tom.primozic@gmail.com>
To: "Brian Hurt" <bhurt@spnz.org>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Type Inference and Overloading
Date: Mon, 10 Apr 2006 16:43:14 +0200	[thread overview]
Message-ID: <c1490a380604100743w2467a2dcg77eea1bc2c1a7bd4@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.63.0604100828560.9896@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 1763 bytes --]

On 10/04/06, Brian Hurt <bhurt@spnz.org> wrote:
>
> > a : int -> float -> int
> > a : float -> int -> int
>
> I'm not sure there is one- in fact, I don't think there is.  Consider if I
> have the following case as above, and then I type:
>
> let g = a;;
>
> what's the type of g?  Is it int -> float -> int or float -> int -> int?


 Hm... I definitely agree that there is no way to find out the type of g in
this case, there do in fact exist 3 ways of how to deal with it:

   1. reject it (i believe this is the "right" way),
   2. have the compiler automatically overload value g, producing two
   functions, or
   3. make one value of a the /default/ value and use the type of that
   one.

As a more general rule, how I deal with overloading in Ocaml is to use
> modules and functors.
>

But I fear you might have misunderstood myself. I am in no way trying either
to convince anyone to implement overloading in OCaml nor saying that there
are no (useful) alternatives. During my quest I have scanned many threads of
this list over and over, and I know that any such suggestions and complaints
are dealt with in a pretty harsh way.

I am young and naive and full of idealistic illusions. So I believe in
overloading. As a great tool for the user. (Haskell's type classes are just
as irritating as the 1.5 + 0. type error, if you ask me.)

My point was, that in cases that function actually DO have a non-ambiguous
type (f1 : float -> int -> int, f1 : int -> int -> float -> int), while it
is quite easy for human to infer it, it (seems) extremely hard for a machine
to do so. Thus I am looking for a (hopefully cheap) mechanism to infer the
types correctly in such cases. I will deal with ambiguities in another way.

[-- Attachment #2: Type: text/html, Size: 2639 bytes --]

  reply	other threads:[~2006-04-10 14:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-10  8:51 Tom Primožič
2006-04-10 11:57 ` [Caml-list] " skaller
2006-04-10 13:42 ` Andrej Bauer
2006-04-10 14:06 ` Brian Hurt
2006-04-10 14:43   ` Tom Primožič [this message]
2006-04-11 16:11 ` Stefan Monnier

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=c1490a380604100743w2467a2dcg77eea1bc2c1a7bd4@mail.gmail.com \
    --to=tom.primozic@gmail.com \
    --cc=bhurt@spnz.org \
    --cc=caml-list@yquem.inria.fr \
    /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).