caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Julien Cohen <jcohen@lami.univ-evry.fr>
To: caml-list@inria.fr
Subject: [Caml-list] inference and phantom types
Date: Mon, 21 Oct 2002 17:23:43 +0200	[thread overview]
Message-ID: <3DB41BFF.4010302@lami.univ-evry.fr> (raw)

I read in the thread 
http://caml.inria.fr/archives/200109/msg00097.html
that phantom types could be used in ocaml but I have some 
troubles understanding the way they really work.

In the following session I use a phantom type ('a,'b)t to 
simulate a list with an additionnal type 'b. I create a special 
cons preserving the type. I create an (int,bool)t value and when 
I make a cons on it and the phantom type seems not to be well 
infered:



         Objective Caml version 3.04

# type ('a,'b) t = 'a list;;
type ('a, 'b) t = 'a list

# let f (x:'a) (y:('a,'b) t) = (x::y : ('a,'b) t);;
val f : 'a -> ('a, 'b) t -> ('a, 'b) t = <fun>

# let (v: (int,bool) t) = [1];;
val v : (int, bool) t = [1]

# f 1 v;;
- : (int, '_a) t = [1; 1]


Is there a fundamental reason for the bool type not to be inferred?
(no response in the ocaml-beginner list)

Thanks
Julien Cohen

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


             reply	other threads:[~2002-10-21 15:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-21 15:23 Julien Cohen [this message]
2002-10-22  1:59 ` Jacques Garrigue

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=3DB41BFF.4010302@lami.univ-evry.fr \
    --to=jcohen@lami.univ-evry.fr \
    --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).