Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] getting the type of a polymorphic data ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Diego Olivier Fernandez Pons <Diego.FERNANDEZ_PONS@e...>
Subject: [Caml-list] getting the type of a polymorphic data ?
    Bonjour,

In a branch and bound program I give the user a generic polymorphic
data structure to represent decision variables, namely a set of
intervals - (domains decrease monotonically)

x = [0 .. 1] U [2 .. 3[
y = [3,5  14,8]

As usual in branch and bound, a value is tried (x = 1) and removed of
the domain if the corresponding branch raises a 'No solution'
exception (x = [0 .. 1[ U [2 .. 3[)

In a preprocessing phase I would like to change the representation of
the decision variables according to their type to avoid degenerancies
like

[0 .. 1[ U ]2 .. 3[ U ]4 .. 5[ -> [0] in the integer case but not with
floats

The problem is that I don't know how to catch the type of a
polymorphic data structure (is this even possible with some magic ?)
to be able to write something like

let x' = match (somemagic.type_of x) with
           | INT -> IntSet.from_poly x
           | FLOAT -> FloatIntervalSet.from_poly x
           | _ -> x

Any hints ?


         Diego Olivier

-------------------
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