From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q45Fc5mZ008676 for ; Sat, 5 May 2012 17:38:05 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsgBAEtIpU/ZSMDjgGdsb2JhbABFsnQiAQELCwsFFgMkgjoTezQBBCiIMwESmSCWOR+KC415gyYElw+EUoN3iVM X-IronPort-AV: E=Sophos;i="4.75,536,1330902000"; d="scan'208";a="156887381" Received: from fmmailgate02.web.de ([217.72.192.227]) by mail1-smtp-roc.national.inria.fr with ESMTP; 05 May 2012 17:38:00 +0200 Received: from moweb002.kundenserver.de (moweb002.kundenserver.de [172.19.20.108]) by fmmailgate02.web.de (Postfix) with ESMTP id 19B9B1C44810C for ; Sat, 5 May 2012 17:38:00 +0200 (CEST) Received: from frosties.localnet ([95.208.118.96]) by smtp.web.de (mrweb002) with ESMTPA (Nemesis) id 0MGARb-1SLWf904oB-00FAq1; Sat, 05 May 2012 17:38:00 +0200 Received: from mrvn by frosties.localnet with local (Exim 4.77) (envelope-from ) id 1SQh3W-00051D-V9 for caml-list@inria.fr; Sat, 05 May 2012 17:37:59 +0200 From: Goswin von Brederlow To: caml-list@inria.fr Date: Sat, 05 May 2012 17:37:58 +0200 Message-ID: <87lil64p0p.fsf@frosties.localnet> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Provags-ID: V02:K0:LwfTvxgRwMzIXl9eE9T5flW29ATAyW4M+kZ5vDYrfNp PlgyzA34xuZjnreM67htXcZ8WtbxolgN1G1bkJJkj2MemQ4u8e 5MfYaMB37rap11MzXQGhyUEsIRBOmHAqBg09nQiEsrqQOlHrJ2 mYuR1NOmUM4lgkAdG1BP6a7EFromPordIPfrfI8NP1lVVPDekl kTs4iKh779FOPv7nLu9KQ== Subject: [Caml-list] How do I declare a value of 'a t instead of '_a t in a module? Hi, I'm writing a module that reimplements the option type without redirection. For that I'm mapping None to a value with all bits set to 0, the NULL pointer in C. For that I have a little helper function: external make_null : unit -> 'a t = "caml_shallow_null" But now I want to also have a polymorphic value for NULL: module Make : sig type 'a t val make_list : unit -> 'a list val make_null : unit -> 'a t end = struct type 'a t let make_list () = [] external make_null : unit -> 'a t = "caml_shallow_null" end module Shallow : sig type 'a t val list : 'a list val null : 'a t end = struct type 'a t = 'a Make.t let list = Make.make_list () let null = Make.make_null () end File "shallow.ml", line 15, characters 6-102: Error: Signature mismatch: Modules do not match: sig type 'a t = 'a Make.t val list : 'a list val null : '_a Make.t end is not included in sig type 'a t val list : 'a list val null : 'a t end Values do not match: val null : '_a Make.t is not included in val null : 'a t What makes the Make.make_list differ from Make.make_null? Is there a way that I can specify that null is still polymorphic or does that only work for constructors like None and compiler magic like []? ---------------------------------------------------------------------- And here something odd: module Make : sig type 'a t = 'a list val make_list : unit -> 'a list val make_null : unit -> 'a t end = struct type 'a t = 'a list let make_list () = [] external make_null : unit -> 'a t = "caml_shallow_null" end module Shallow : sig type 'a t val list : 'a list val null : 'a t end = struct type 'a t = 'a Make.t let list = Make.make_list () let null = Make.make_null () end compiles fine. But module Make : sig type 'a t = private 'a list val make_list : unit -> 'a list val make_null : unit -> 'a t end = struct type 'a t = 'a list let make_list () = [] external make_null : unit -> 'a t = "caml_shallow_null" end module Shallow : sig type 'a t val list : 'a list val null : 'a t end = struct type 'a t = 'a Make.t let list = Make.make_list () let null = Make.make_null () end fails again. Just making the Make.t private makes it fail. MfG Goswin