caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Damien Doligez <damien.doligez@inria.fr>
To: caml Caml <caml-list@inria.fr>
Subject: Re: [Caml-list] getting the type of a polymorphic data ?
Date: Thu, 12 Aug 2004 15:38:14 +0200	[thread overview]
Message-ID: <DC3752B6-EC64-11D8-B20D-00039310CAE8@inria.fr> (raw)
In-Reply-To: <Pine.A41.4.44.0408121356110.557174-100000@ibm1>

On Aug 12, 2004, at 14:09, Diego Olivier Fernandez Pons wrote:

> It seems that Obj.is_int does exactly that (determining if a type is
> isomorphic to a subset of integers).

No, not exactly:

         Objective Caml version 3.09+dev0 (2004-07-13)

# type x = A | B of int;;
type x = A | B of int
# Obj.is_int (Obj.repr A);;
- : bool = true
# Obj.is_int (Obj.repr (B 1));;
- : bool = false

All Obj.is_int tells you about the _type_ of its argument is that,
if it returns true then at least one of the type's values is
represented as an integer.


> Is it reasonable to admit that if Obj.is_int is true for x and y then
> Hashtbl.hash is injective ?
>
> hash x = hash y => x = y (for structural polymorphic equality)

Not quite.

# Hashtbl.hash 0x4000_0000;;
- : int = 0
# Hashtbl.hash 0;;
- : int = 0

-- Damien

-------------------
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:[~2004-08-12 13:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.A41.4.44.0408121350120.557174-100000@ibm1>
2004-08-12 12:09 ` Diego Olivier Fernandez Pons
2004-08-12 13:38   ` Damien Doligez [this message]
2004-08-12 13:57     ` Diego Olivier Fernandez Pons
2004-08-12 14:13       ` Marcin 'Qrczak' Kowalczyk
2004-08-12 14:26         ` Diego Olivier Fernandez Pons
2004-08-12 18:18 Jean-Baptiste Rouquier
2004-08-13  8:15 ` Diego Olivier Fernandez Pons
2004-08-13  8:59 ` Diego Olivier Fernandez Pons
     [not found] <20040812143443.2aba80c1@babasse>
2004-08-12 12:47 ` Diego Olivier Fernandez Pons
  -- strict thread matches above, loose matches on Subject: below --
2004-08-06 15:05 Diego Olivier Fernandez Pons

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=DC3752B6-EC64-11D8-B20D-00039310CAE8@inria.fr \
    --to=damien.doligez@inria.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).