From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id D84C37F7C2 for ; Wed, 5 Feb 2014 21:29:56 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alain@frisch.fr) identity=pra; client-ip=80.12.242.127; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="alain@frisch.fr"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alain@frisch.fr) identity=mailfrom; client-ip=80.12.242.127; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="alain@frisch.fr"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@smtp.smtpout.orange.fr) identity=helo; client-ip=80.12.242.127; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="postmaster@smtp.smtpout.orange.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgwCAGWe8lJQDPJ/lGdsb2JhbABZg0S/L4EmDgEBAQEHCwsJEiqCJQEBBScRMw0RCxgJFg8JAwIBAgFFBgEMCAEBiAUJznAXjnyEOAEDmCuBMoUWjwc X-IPAS-Result: AgwCAGWe8lJQDPJ/lGdsb2JhbABZg0S/L4EmDgEBAQEHCwsJEiqCJQEBBScRMw0RCxgJFg8JAwIBAgFFBgEMCAEBiAUJznAXjnyEOAEDmCuBMoUWjwc X-IronPort-AV: E=Sophos;i="4.95,788,1384297200"; d="scan'208";a="57036406" Received: from smtp05.smtpout.orange.fr (HELO smtp.smtpout.orange.fr) ([80.12.242.127]) by mail2-smtp-roc.national.inria.fr with ESMTP; 05 Feb 2014 21:29:56 +0100 Received: from [192.168.1.22] ([82.124.19.193]) by mwinf5d28 with ME id NkVw1n00G49wfuy03kVw8t; Wed, 05 Feb 2014 21:29:56 +0100 Message-ID: <52F29F45.6070003@frisch.fr> Date: Wed, 05 Feb 2014 21:29:57 +0100 From: Alain Frisch User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Yotam Barnoy , Ocaml Mailing List References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Default methods for module signatures I proposed (13 years ago...) a small patch to support optional fields in modules. This would help achieving the desired effect. See: http://alain.frisch.fr/info/patch-option-announce http://alain.frisch.fr/info/patch-option -- Alain On 2/5/2014 7:49 PM, Yotam Barnoy wrote: > Hello List > > I would like the following feature, and I'm not enough of an expert in > module-fu to know if something like this is doable. > > Suppose I have a module signature of > > module type Monad = sig > type 'a m > val return : 'a -> 'a m > val (>>=) : 'a m -> ('a -> 'b m) -> 'b m > val (>>) : 'a m -> 'b m -> 'b m > end > > I would like to have a default implementation for (>>), since a simple > default implementation is > > let (>>) m f = m >>= fun _ -> f > > Alternatively, I would like to include this from some DefaultMonad > module, but have the (>>=) referred to in the function be my newly > defined (>>=) implementation (ie. late binding). Is there currently any > way to do this? If not, would there be a way to implement a partial > default implementation built into or associated with a module signature? > Something like > > module type Monad = sig... default struct... end > > Haskell has this available as part of the semantics of their typeclass > system, and I think it would be really handy to have (if there isn't > already a way to do it currently). > > -Yotam > >