caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Ohad Rodeh" <ORODEH@il.ibm.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] mutability analysis too strict?
Date: Mon, 10 Dec 2001 12:13:19 +0200	[thread overview]
Message-ID: <OFF96B3E7D.145DD6FC-ONC2256B1E.00379C10@telaviv.ibm.com> (raw)


> Sent by:     owner-caml-list@pauillac.inria.fr

> To: caml-list@inria.fr
> cc:
> Subject:     Re: [Caml-list] mutability analysis too strict?



> "Ohad Rodeh" <ORODEH@il.ibm.com> writes:

> > First of all, sorry my mail was sent twice, this was due to mail
delivery
> > problems
> > from my site.
> >
> > Perhaps I was not specific enough about what I wanted to acheive. What
I
> > need
> > is a repository that has the following interface:
> >
> > module type Repos = sig
> >   val put : 'a -> 'b -> unit
> >   val get : 'a -> 'b
> > end
> >
> > An  implementation that looks like this:
> >
> > module S : Repos = struct
> >    let h = Hashtbl.create 10
> >    let put key data = Hashtbl.add h key data
> >    let get key = Hashtbl.find h key
> > end
> >
> > Does not work. Compilation error:
> >
> > Signature mismatch:
> > Modules do not match:
> >   sig
> >     val h : ('_a, '_b) Hashtbl.t
> >     val put : '_a -> '_b -> unit
> >     val get : '_a -> '_b
> >   end
> > is not included in
> >   Repos
> > Values do not match:
> >   val put : '_a -> '_b -> unit
> > is not included in
> >   val put : 'a -> 'b -> unit
> >
> > I tried also using the Map and Set modules, but they don't really allow
> > building
> > a repository of immutable values either. Is there any deep reason for
this
> > behavior? Could you expound on this line:
> >
> > > A monomorphic, mutable
> > > structure that contains polymorphic data is sound, but cannot be
> > expressed
> > > in ML's type system where universal quantification must be prenex.
> >
> > Ohad.



Remi VANICAT <vanicat@labri.u-bordeaux.fr>@pauillac.inria.fr on 10/12/2001
11:28:42

> it's dangerous. Imagine you can do :
>
> put 2 "xd"
>
> what will be the type of :
>
> get 2
>
> how the type inference algorithm can know that it is a string ? it
> can't because you can do something like :
>
> if x < y then put 2 "xd"
> else put 2 5
>
> and then, the type of get 2 wil be string or int depending on the fact
> that x was less than y or not.



Well, that's a strong argument ...

How do you propose building a repository of polymorphic values then?

     Ohad.


-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


             reply	other threads:[~2001-12-10 10:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-10 10:13 Ohad Rodeh [this message]
2001-12-10 10:30 ` Basile STARYNKEVITCH
2001-12-10 10:50 ` Francois Pottier
2001-12-10 11:21 ` Mark Seaborn
  -- strict thread matches above, loose matches on Subject: below --
2001-12-10  9:12 Ohad Rodeh
2001-12-10  9:28 ` Remi VANICAT
2001-12-09 15:43 Ohad Rodeh
2001-12-10  8:13 ` Francois Pottier
2001-12-09 12:14 [Caml-list] Mutability " Ohad Rodeh

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=OFF96B3E7D.145DD6FC-ONC2256B1E.00379C10@telaviv.ibm.com \
    --to=orodeh@il.ibm.com \
    --cc=caml-list@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).