Browse thread
[Caml-list] checking for same ctor type?
- Chris Hecker
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Chris Hecker <checker@d...> |
| Subject: | [Caml-list] checking for same ctor type? |
What's the right way to check if two variants have the same ctor, but
not necessarily the same values in the ctor parms?
For example, I want to check if both data_types are Strings:
type data_type =
String of string
| Float of float
let a = String "foo"
let b = String "bar"
let c = Float 2.0
let ctor_equal a b = ???
ctor_equal a b = true
ctor_equal a c = false
I can think of a couple definitions of ctor_equal, one using
Hashtbl.hash_param 1 1 and one using Obj.tag (which both appear to be
doing the same thing). Both of these seem a bit cheesy and
implementation dependent.
Is there a better way?
Chris
-------------------
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