Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Polymorphic variants and signatures
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: brogoff@s...
Subject: [Caml-list] Polymorphic variants and signatures
Hi, 
    I've run into some issues with polymorphic variants that I can't find 
addressed in the manual. I'd like to define a module type which looks 
(simplified) like this

module type CELL_TYPE =
  sig
    type ('a, 'b) t

    val show_rec :
        ('a -> ('b -> string) -> string) -> ([< ('b, 'a) t ] *  'c) inst ->
            ('b -> string) -> string
    ...

  end

and obviously I can't because ('a, 'b) t is not a polymorphic variant type. 

Is there some way I can write such a module type, and, after having written it, 
use it in a functor as follows, 

module Make (Cell : CELL_TYPE) = 
  struct 
    type ('a, 'b) t = [`Newtag of 'b list | ('a, 'b) Cell.t]

    (* and some dispatch on `Newtag and #Cell.t *)
  end

-- 
-- Brian

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