Question about GADT

"Stephane Legrand [email protected] [ocaml_beginners]" <[email protected]> Thu, 3 Dec 2015 23:34:06 +0100
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <[email protected]>
Hello,

I'm trying to run the code below. The compiler gives me an error for the 
"print_endline x" line: "This expression has type ex#0 but an expression 
was expected of type string". Is there a way to fix this error? If this 
kind of thing is doable with GADT? Thank you.

type _ data =
   Int : int -> int data
   | String : string -> string data

type t =
   Wrap : _ data -> t

let data_int v = Wrap(Int v)
let data_string v = Wrap(String v)

let to_ocaml_value : type a. a data -> a = function
   | Int v -> v
   | String v -> v

let test = data_string "test"

let () =
   match test with
   | Wrap v ->
       let x = to_ocaml_value v in
       print_endline x


Regards,
Stéphane.