caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Walter Cazzola <cazzola@dico.unimi.it>
To: Christophe Papazian <christophe.papazian@gmail.com>
Cc: OCaML Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] still silly issues on polymorphic types
Date: Tue, 27 Sep 2011 20:43:40 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LFD.2.00.1109272040391.2778@surtur.dico.unimi.it> (raw)
In-Reply-To: <53C8B18E-A3AD-4DB1-A477-EE7FA7846845@gmail.com>

On Tue, 27 Sep 2011, Christophe Papazian wrote:

>> uhm, I have a couple of questions I don't understand on your
>> explanation:
>> - why the most general type is int->'a and not 'a -> 'b?

> Because if I need a function of type int -> 'a I can give a function of type 
> 'a -> 'b.
> But if I need a function of type 'a -> 'b I can not use a function of type 
> int -> 'a.
> So int -> 'a is more general and 'a -> 'b is more specific.

> General rule : if a < b then (a->c) > (b->c)

probably this is a question whose answer will be RTFM but I'll try to
get your mercy (;-)): what define that a is lesser than b? is there a
table of the precendece among types?

>> - does this mean that I can't have a general type that could be matched
>>  by 'a -> 'a list -> 'a list  and int -> int -> int ?

> if you want to get a supertype of a -> b and c -> d you need to
> find a subtype of a and c AND find a supertype of b and d.

> So for example for ('a -> ( 'a list -> 'a list)) and (int -> (int -> int))
> you need
> - a subtype of 'a and int : it's int. you have one.
> - a supertype of ('a list -> 'a list) and (int -> int) (reapply the same 
> procedure)
>     -a subtype of 'a list and int : there is no such thing in ocaml, so 
> there is no supertype.

ok I see

> So to answer your question, you can't. But as Jacques Garrigue said, you 
> don't need either, and you can use abstract type and "with type"
> construction.

uhm, as I replied to Jacques I tried but the error persists probably I
don't know enough OCaML to do that.

thanks a lot
Walter

-- 

  reply	other threads:[~2011-09-27 18:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-27 11:46 Walter Cazzola
2011-09-27 12:57 ` Christophe Papazian
2011-09-27 13:49   ` Walter Cazzola
2011-09-27 15:26     ` Christophe Papazian
2011-09-27 18:43       ` Walter Cazzola [this message]
2011-09-27 19:25         ` Thibault Suzanne
2011-09-27 13:16 ` Jacques Garrigue
2011-09-27 13:58   ` Walter Cazzola
2011-09-27 19:45     ` Pierre Chopin
2011-09-27 20:22       ` Walter Cazzola
2011-09-27 23:58         ` Jacques Garrigue
     [not found]         ` <266E7048-C3BB-4B9E-9760-9D52993A1C86@math.nagoya-u.ac.jp>
2011-09-29 10:27           ` Walter Cazzola

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=alpine.LFD.2.00.1109272040391.2778@surtur.dico.unimi.it \
    --to=cazzola@dico.unimi.it \
    --cc=caml-list@inria.fr \
    --cc=christophe.papazian@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).