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 86D457F7C2 for ; Wed, 5 Feb 2014 19:49:52 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of yotambarnoy@gmail.com) identity=pra; client-ip=209.85.216.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yotambarnoy@gmail.com"; x-sender="yotambarnoy@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of yotambarnoy@gmail.com designates 209.85.216.180 as permitted sender) identity=mailfrom; client-ip=209.85.216.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yotambarnoy@gmail.com"; x-sender="yotambarnoy@gmail.com"; 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@mail-qc0-f180.google.com) identity=helo; client-ip=209.85.216.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yotambarnoy@gmail.com"; x-sender="postmaster@mail-qc0-f180.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjsCAFyH8lLRVdi0lGdsb2JhbABZhBu/VAgWDgEBAQEHCwsJEiqCUxkBGw8PAxIJB10BEQEFASKIAwEDEZ49gwqMXoMJk3sKGScNZIgqEQEFDJMoBIlJjmKQNBgphHce X-IPAS-Result: AjsCAFyH8lLRVdi0lGdsb2JhbABZhBu/VAgWDgEBAQEHCwsJEiqCUxkBGw8PAxIJB10BEQEFASKIAwEDEZ49gwqMXoMJk3sKGScNZIgqEQEFDJMoBIlJjmKQNBgphHce X-IronPort-AV: E=Sophos;i="4.95,788,1384297200"; d="scan'208";a="47933989" Received: from mail-qc0-f180.google.com ([209.85.216.180]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 05 Feb 2014 19:49:51 +0100 Received: by mail-qc0-f180.google.com with SMTP id i17so1354905qcy.11 for ; Wed, 05 Feb 2014 10:49:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=fTQkCNt0orfUJvG/00tKOpubTt+2ARExfRmZoqFw/zk=; b=s8FUOoC/RjrIlHBgmMw+Ajmi0fMc8svIlo26UjrhF7tklbyhICG/msK/HdR61AgBHN 5Gf0EtMLvgHe0a3wUNqT/OnDNisewiBIppWWO9yKhbONgUKzMdfcbELKW8upVtJUsfHh 4iD0b85vUwsYEE5WBdlXHVTJL0R2wI7Ld3+Y1vlVHbYhHibOHBC7NGABH/Fs3A0bMfSW /8So6eDj1kqJUl6GPvfPxcrh87/Buyc5huOmTDksjdZpsxtOdQUWid1Mb9kXDk7DDIbG wXd0iVjKfXpbIFhV9Ny6apBzEnKNm82NV7LuxnJemvNpU8f1mVDgwQ3NoZtj8mBlBEYN ajng== X-Received: by 10.224.160.195 with SMTP id o3mr5364781qax.98.1391626189978; Wed, 05 Feb 2014 10:49:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.224.106.137 with HTTP; Wed, 5 Feb 2014 10:49:29 -0800 (PST) From: Yotam Barnoy Date: Wed, 5 Feb 2014 13:49:29 -0500 Message-ID: To: Ocaml Mailing List Content-Type: multipart/alternative; boundary=089e0153695cb6c17404f1ad387c Subject: [Caml-list] Default methods for module signatures --089e0153695cb6c17404f1ad387c Content-Type: text/plain; charset=ISO-8859-1 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 --089e0153695cb6c17404f1ad387c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hello List

I would like the following feature, and= I'm not enough of an expert in module-fu to know if something like thi= s is doable.

Suppose I have a module signature of

module type Monad =3D= sig
=A0 type 'a m
=A0 val return : 'a -> '= ;a m
=A0 val (>>=3D) : 'a m -> ('a -> 'b m= ) -> 'b m
=A0 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 =3D m >>=3D fun _ -> f

Alternatively, I would like to include this from some Defau= ltMonad module, but have the (>>=3D) referred to in the function be m= y newly defined (>>=3D) implementation (ie. late binding). Is there c= urrently any way to do this? If not, would there be a way to implement a pa= rtial default implementation built into or associated with a module signatu= re? Something like

module type Monad =3D sig... default struct... end

H= askell has this available as part of the semantics of their typeclass syste= m, and I think it would be really handy to have (if there isn't already= a way to do it currently).

-Yotam
=


--089e0153695cb6c17404f1ad387c--