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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 93A457EEEF for ; Tue, 23 Jun 2015 10:42:41 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of oleg@okmij.org) identity=pra; client-ip=66.39.3.114; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="oleg@okmij.org"; x-sender="oleg@okmij.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of oleg@okmij.org designates 66.39.3.114 as permitted sender) identity=mailfrom; client-ip=66.39.3.114; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="oleg@okmij.org"; x-sender="oleg@okmij.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail1.g3.pair.com) identity=helo; client-ip=66.39.3.114; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="oleg@okmij.org"; x-sender="postmaster@mail1.g3.pair.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DMAAC/GolVnHIDJ0JbygSBREwBAQEBAQESAQEBAQEICwkJIS6EJAQ7PwU3NAWJAwjMCyyQUB2DAYEUBYx8hwOBL4ohAYJnlU6CMhyBYYMoAQEB X-IPAS-Result: A0DMAAC/GolVnHIDJ0JbygSBREwBAQEBAQESAQEBAQEICwkJIS6EJAQ7PwU3NAWJAwjMCyyQUB2DAYEUBYx8hwOBL4ohAYJnlU6CMhyBYYMoAQEB X-IronPort-AV: E=Sophos;i="5.13,664,1427752800"; d="scan'208";a="137455539" Received: from mail1.g3.pair.com ([66.39.3.114]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 23 Jun 2015 10:42:40 +0200 Received: from Magus.sf-private (fortigate.sf.ecei.tohoku.ac.jp [130.34.188.206]) by mail1.g3.pair.com (Postfix) with ESMTPSA id 79EB633E22; Tue, 23 Jun 2015 04:42:37 -0400 (EDT) Date: Tue, 23 Jun 2015 17:50:11 +0900 From: Oleg To: caml-list@inria.fr Cc: asai@is.ocha.ac.jp Message-ID: <20150623085011.GA1283@Magus.sf-private> Mail-Followup-To: Oleg , caml-list@inria.fr, asai@is.ocha.ac.jp MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.22 (2013-10-16) Subject: [Caml-list] Labels at the module level? > I want to define a functor that accepts a module of sig: > module type A_t = sig > val x : int > val y : int > end > but if the user did not specify some of the values in the signature, > some default values will be used. It is even easier at the module level: include comes in handy. Suppose we have a consumer module Universe(Params: A_t) = struct let r () = Printf.printf "x = %d y = %d\n" Params.x Params.y end;; First, we define defaults: module Def : A_t = struct let x = 1 let y = 2 end;; We can invoke it as let module M = Universe(Def) in M.r ();; and also as let module M = Universe(struct include Def let x = 100 end) in M.r ();; BTW, groups of related parameters could be further grouped into submodules.