From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 310287ED5C for ; Fri, 3 Aug 2012 16:20:35 +0200 (CEST) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of darioteixeira@yahoo.com) identity=pra; client-ip=98.139.91.77; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="darioteixeira@yahoo.com"; x-sender="darioteixeira@yahoo.com"; x-conformance=sidf_compatible Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of darioteixeira@yahoo.com) identity=mailfrom; client-ip=98.139.91.77; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="darioteixeira@yahoo.com"; x-sender="darioteixeira@yahoo.com"; x-conformance=sidf_compatible Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@nm7.bullet.mail.sp2.yahoo.com) identity=helo; client-ip=98.139.91.77; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="darioteixeira@yahoo.com"; x-sender="postmaster@nm7.bullet.mail.sp2.yahoo.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApIFAG/dG1Bii1tNXWdsb2JhbAA4DagIkSsXCgoHEwYkghsXARsEFQECFSIBFHoBDgEEAhiIEAEBAgwEmxeGTohCCYJohSsBIwMBIwOJUQEGCgEBkkADiE2NBIVULU2IXINb X-IronPort-AV: E=Sophos;i="4.77,706,1336341600"; d="scan'208";a="152386375" Received: from nm7.bullet.mail.sp2.yahoo.com ([98.139.91.77]) by mail4-smtp-sop.national.inria.fr with SMTP; 03 Aug 2012 16:20:33 +0200 Received: from [98.139.91.62] by nm7.bullet.mail.sp2.yahoo.com with NNFMP; 03 Aug 2012 14:20:31 -0000 Received: from [98.139.91.29] by tm2.bullet.mail.sp2.yahoo.com with NNFMP; 03 Aug 2012 14:20:31 -0000 Received: from [127.0.0.1] by omp1029.mail.sp2.yahoo.com with NNFMP; 03 Aug 2012 14:20:31 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 843273.82175.bm@omp1029.mail.sp2.yahoo.com Received: (qmail 71641 invoked by uid 60001); 3 Aug 2012 14:20:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1344003631; bh=2OCCC5J+fzgHBSCJ+h8qBTvMV1A7zwVR9EGt9uqEUvA=; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=OPv2pHBxxfi0Bm84KeFctquNGnlbTR1HzIBijkQ3HXfVW/6qf4MqN0aPqAg4+py5uYG00EYeGptYZda7VmF0cnmHdsDkrSzKVJ1meFXh9WWwN1zDUtLmjOgNLH4SYXL6EHaCv+oOSn/dLj7E56vOnBuJnLx5UHKSVD8Ri/EsaQ4= DomainKey-Signature:a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=v72L63EyMOtPrRZSD6o/oEdBV3oiFspcaJ5JolAM6N1Eyv2sUkuidlcbCCQhk9zpfUl7+QNw2N9+V2FgBEliUr46I/y2zQlDIBLw+NVNCdzLZOxsOr1vdH1jIEG73nU9pvnzwK7/87Nb8Zo1owvYIti+2xEhFYqXrSGg1r+G02A=; X-YMail-OSG: _MZkfyUVM1k7LzBJ2pcrzR1T8ClBcBwZ.HWCXQsAD0xjxUl TQDMo5GLKkUggBFvUnXmDhDfCR6X4QTBXGWl6ZuMhl_EoI0YhjbHKvDtiEaq trPgW0QFSwQPU1dMFYCp1h7m2k0PZno7ClPnlSCp6jr5vkQyzvasQ03uATP8 5sfJPwLOI3qn5EY4NwN6EeAr0QwwOFNEKKO8JU48qOAUOK9b2oXy02QSdp_T TrZAekiUTZ2uM3ay10EXi6IYV2FddHSnnaTnmXCGTCuv904DA4tfuE.JK0Cj Rs6.4ekWm9wgLNHU0Ha1XNoVj_VsaV4lCYm9rU_0cbUYGQk57TAc1xdbV6Zj ag_Ix8XAzFFvCKxEJlnqF7TqmxPqMxr4tX7u8P2wZ80P1dYA.0tOeVY271_d fGcZtnTWyY9r9wwqtZMimDKMOhuhFeVaLLhpUUK88WYa3BMzN1auV.5h5lgr KyNB5IK5xYZoc9B_hGgnxXVok Received: from [195.23.80.29] by web111509.mail.gq1.yahoo.com via HTTP; Fri, 03 Aug 2012 07:20:31 PDT X-Mailer: YahooMailWebService/0.8.120.356233 Message-ID: <1344003631.53140.YahooMailNeo@web111509.mail.gq1.yahoo.com> Date: Fri, 3 Aug 2012 07:20:31 -0700 (PDT) From: Dario Teixeira Reply-To: Dario Teixeira To: O Caml Mailing List MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Subject: [Caml-list] The "dummy" monad Hi, I have a question about terminology.=A0 Suppose I have a functor whose implementation relies on a "get" function defined in the functor's paramete= r, which is a module of type GETTER.=A0 I want this functor to handle GETTER implementations which may rely on the lightweight threads of Lwt.=A0 The ke= yword is "may", because I also want to allow GETTER implementations using another monad other than Lwt's, or implementations not using any monad altogether. To implement this I'm using a technique inspired by J=E9r=F4me Vouillon's refactorisation of PG'OCaml to work in a monadic style.=A0 Essentially, I require any module implementing GETTER to define the monad it uses: module type GETTER =3D sig =A0=A0=A0 module Monad: =A0=A0=A0 sig =A0=A0=A0=A0=A0=A0=A0 type 'a t =A0=A0=A0=A0=A0=A0=A0 val return: 'a -> 'a t =A0=A0=A0=A0=A0=A0=A0 val fail: exn -> 'a t =A0=A0=A0=A0=A0=A0=A0 val bind: 'a t -> ('a -> 'b t) -> 'b t =A0=A0=A0=A0=A0=A0=A0 val catch: (unit -> 'a t) -> (exn -> 'a t) -> 'a t =A0=A0=A0 end =A0=A0=A0 val get: string -> string Monad.t end An implementation "Mygetter1" using Lwt can be defined as follows: module Mygetter1: GETTER with type 'a Monad.t =3D 'a Lwt.t =3D struct =A0=A0=A0 module Monad =3D Lwt =A0=A0=A0 let get x =3D ... end Whereas an implementation not requiring any special monad would be defined as listed below, in essence defining a "dummy" monad. module Mygetter2: GETTER with type 'a Monad.t =3D 'a =3D struct =A0=A0=A0 module Monad =3D =A0=A0=A0 struct =A0=A0=A0=A0=A0=A0=A0 type 'a t =3D 'a =A0=A0=A0=A0=A0=A0=A0 let return x =3D x =A0=A0=A0=A0=A0=A0=A0 let fail x =3D raise x =A0=A0=A0=A0=A0=A0=A0 let bind t f =3D f t =A0=A0=A0=A0=A0=A0=A0 let catch t f =3D try t () with exc -> f exc =A0=A0=A0 end =A0=A0=A0 let get x =3D ... end Now, I suspect this is a well-known technique in monad-breathing circles. But what is it called?=A0 In particular, what should I be calling the "dumm= y" monad? Thanks in advance! Best regards, Dario Teixeira