From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id DD7ED7ED7A for ; Tue, 18 Sep 2012 23:13:54 +0200 (CEST) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.217.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.217.182 as permitted sender) identity=mailfrom; client-ip=209.85.217.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-lb0-f182.google.com) identity=helo; client-ip=209.85.217.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-lb0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsQBAGHjWFDRVdm2m2dsb2JhbABFqk+RbAgjAQEBAQEICQsJFCeCIAEBAQQSAiwBGxILAQMMBgULAwoNISEBAREBBQEKEgYTCAoQh04BAwwLm1UJA4wlgnOFJgoZJwMKWYh0AQUMii1ihnADlA6BVYEUigODKxYphAg X-IronPort-AV: E=Sophos;i="4.80,445,1344204000"; d="scan'208,223";a="156181816" Received: from mail-lb0-f182.google.com ([209.85.217.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 18 Sep 2012 23:13:54 +0200 Received: by lbbgg13 with SMTP id gg13so550291lbb.27 for ; Tue, 18 Sep 2012 14:13:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=mK5nOQzG2PqbtDLB97/AlNFE7+noFds78T6v7pNu2A0=; b=mACG5U3tlvHhvuWOufTMN9PnBMTXl4vVixsqi+Md6L+zGFhXSSInUuuuLsx1UojoMd f2uL7y/SU+6UHJ0LkQGpWj8CjiCor4DtQ8XU1mKlLD/8idHNiq4flqdfdtTh8iJXEcBW jEHXsNMZMtDuLm4gjILihjAf+//KHlSJ94kvEg74te0P1PSZgQlCuTbG9bpjDrDNyOXo XweaJMTSiBtL93+bWTrjZjK5fk2s05z1iGGzn/X8FgJ0MFE+/09ZrkXurGqxp9Qy2Tuk oxg1BYWuGmaWLCotiDxEoH/S0zhjARLzEQs/JPLZP6+6QzIfbmECboz+f4NcoR9BT9xS 6mZw== Received: by 10.152.124.180 with SMTP id mj20mr864758lab.43.1348002833347; Tue, 18 Sep 2012 14:13:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.111.33 with HTTP; Tue, 18 Sep 2012 14:13:12 -0700 (PDT) In-Reply-To: References: From: Gabriel Scherer Date: Tue, 18 Sep 2012 23:13:12 +0200 Message-ID: To: Malcolm Matalka Cc: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] Expressing module sig and impl in mli file >From the outside, there is no point in trying to make a difference between an "interface" and "concrete types": what users see of the module is exactly its interface, just as what you see of a value (through an interface boundary) is its type only. There are exotic cases where you could want to publish a value definition (or module implementation) through a component boundary, but that's probably not your concern here. So my intuitive answer (but maybe some other posters will differ) is that, in an interface, only "module Foo : Bar" makes sense. I do not understand why you would want the implementation to also be available. You may be facing a problem that is different than the one you think. Could you provide a concrete example of what you're trying to do? Making a guess: a mistake people often make when using the OCaml module system is to seal a module with abstract types when they actually don't want to hide the types, but only to check that the signature are compatible. For example, with the signature "module type Ty = sig type t end", people will try to write "module M : Ty = struct type t = int end" and then be surprised than "(1 : M.t)" does not type-check. This is because "module M : Ty = " is equivalent to "module M = ( : Ty)" which coerces into the signature Ty (where "t" is abstract), and no richer. A workaround is to define "module M = " and then separately "module M_unused = (M : Ty)" if you want to make sure that the interface is compatible, or to refine it with "module M : (Ty with type t = int) = ". Not sure that is actually your problem, though. Finally, if you have a module implementation and are not sure what its precise, most permissive signature is, "ocamlc -i" can help you by printing the inferred interface. On Tue, Sep 18, 2012 at 11:02 PM, Malcolm Matalka wrote: > I'm sure this question has been asked before but I didn't see it in > the Ocaml FAQ and I'm not sure how to express it for a search. > > In short, how do I express the following line in a .mli file: > > module Foo : Bar = Baz > > What I want to accomplish is make present the module Foo to the user, > where they know both the interface and the concerete types on Foo. > > Thanks! > > /Malcolm > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >