From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p3D4T4lP027563 for ; Wed, 13 Apr 2011 06:29:04 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArMBADImpU3Y5v4tmWdsb2JhbACESpJ/jj0UAQEBAQEGDQsHFCWBDbIvAYkqiA+BJoNNewSFWogJg28 X-IronPort-AV: E=Sophos;i="4.64,202,1301868000"; d="scan'208";a="92760708" Received: from amout05.alpha-mail.net ([216.230.254.45]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 13 Apr 2011 06:28:58 +0200 Received: from webarc02.alpha-mail.jp (webarc02 [216.230.254.82]) by amout05.alpha-mail.net with ESMTP id p3D4Srh4007056; Wed, 13 Apr 2011 13:28:53 +0900 X-Virus-Scanned: amavisd-new at Alpha-Mail Out Received: from ltpri01.alpha-lt.net (ltpri01.alpha-lt.net [216.230.254.22]) by webarc02.alpha-mail.jp (Postfix) with ESMTP id 29B1A131005C; Wed, 13 Apr 2011 13:28:51 +0900 (JST) Received: from [192.168.0.105] (196.62.205.61.west.global.alpha-net.ne.jp [61.205.62.196]) by ltpri01.alpha-lt.net (Alpha-mail) with ESMTP id 69536B1C07E; Wed, 13 Apr 2011 13:28:53 +0900 (JST) Message-ID: <4DA52686.40200@itpl.co.jp> Date: Wed, 13 Apr 2011 13:28:54 +0900 From: Satoshi Ogasawara User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; ja; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 To: caml-list Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Subject: [Caml-list] concept style using first-class module Hello, Recently I learned concept style generic programming like Haskell type-class. I'd like to emulate that style in OCaml using first-class modules. e.g. module type Monad = sig type 'a t val return : 'a -> 'a t val bind : 'a t -> ('a -> 'b t) -> 'b t end module type MonadPlus = sig type 'a t include Monad with type 'a t := 'a t val zero : 'a t val plus : 'a t -> 'a t -> 'a t end let foo (module M:MonadPlus) m = M.bind m (fun x -> M.return x) But above code makes an error at the last line. Error: This `let module' expression has type 'a M.t -> 'a M.t In this type, the locally bound module name M escapes its scope I have tried to add a (type s) parameter and specialize module types but It's not work. How can I make this code typable? Is it impossible without higher order type operator? Regards, ogasawara