From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.8 required=5.0 tests=DNS_FROM_RFC_POST,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id B5C5EBBC4 for ; Fri, 17 Apr 2009 22:51:46 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkgDAJOI6ElKfS4fkGdsb2JhbACVej8BAQEBCQkMBxEDqFEyhxKISAEDAQODegaGMg X-IronPort-AV: E=Sophos;i="4.40,206,1238968800"; d="scan'208";a="24767717" Received: from yw-out-2324.google.com ([74.125.46.31]) by mail2-smtp-roc.national.inria.fr with ESMTP; 17 Apr 2009 22:51:46 +0200 Received: by yw-out-2324.google.com with SMTP id 5so723483ywh.3 for ; Fri, 17 Apr 2009 13:51:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=EiDWraW2CK0B7NP2HOEUBt9siJqenBSRpq6niOvH3qA=; b=Ask5xwGMNmtzDVZPh1Kmd5fg1ob60bIAbsJJqpxuX959M9zqZJYb4vLuMCQ/9+lYS+ 29HZsbmZZpgWTIlTevx7U/ScFl4bvM8yoz4J1Q51V1Io73AK/df8xeIJR0mJzLNADE04 F6Zk1P4bhfxHLVzAAahqBzq+xa+xM9zxUt2p8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type:content-transfer-encoding; b=lJxUfWYBgLLO7X4nSUdpOkk5IfJ5S+ticFY7H3C9N4XtCKiWK9qaqpQd5dbKyskvOV 40sn0i+rRJu8cImcwfq1GFApImqJ7dMoi9//I+7t7MduvNJkcHxCCCuy99FgBy9NsxkJ 8twuERO9MBlqFlkKfPvIU6D1Eu2qOPZ33G8xo= MIME-Version: 1.0 Sender: peter.hawkins@gmail.com Received: by 10.100.252.18 with SMTP id z18mr4329242anh.111.1240001505313; Fri, 17 Apr 2009 13:51:45 -0700 (PDT) Date: Fri, 17 Apr 2009 13:51:45 -0700 X-Google-Sender-Auth: 5c84897aee991e39 Message-ID: Subject: Extending modules and signatures From: Peter Hawkins To: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; mylist:01 struct:01 foo:01 mli:01 mli:01 mylist:01 sig:01 val:01 foo:01 val:01 cheers:01 ideally:01 signatures:01 functions:01 define:02 Hi... I have a quick question. I want to extend the List module with various functions that I want that aren't present in the standard library, much as the Batteries ExtList library does. I might write the following code in "mylibrary.ml": module MyList = struct include List let foo x = ... code here let bar y = ... code here end That's ok so far, but now suppose I want to write a "mylibrary.mli" interface file corresponding to "mylibrary.ml". Ideally I'd write something like this in "mylibrary.mli": module MyList : sig include List (* unknown module type List *) val foo : ... val bar : ... end Unfortunately I can't include "List" here since it is a structure, not a signature. I don't think there is a way to say "include the signature associated with List". I can think of three solutions: a) Copy the complete signature of List into MyList. This is a bad idea since the List module might change in the future. This is what the Batteries ExtList module does. b) Alter the List module to define a signature, say List.S, in addition to its other contents. I can't easily do this since I didn't write the List module. c) Don't write a .mli file at all. Are there any other alternatives? Cheers, Peter