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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 1BB0F7EC41 for ; Tue, 23 Oct 2012 09:57:01 +0200 (CEST) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.223.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.223.182 as permitted sender) identity=mailfrom; client-ip=209.85.223.182; receiver=mail1-smtp-roc.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 (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ie0-f182.google.com) identity=helo; client-ip=209.85.223.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-ie0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqkBAA9NhlDRVd+2m2dsb2JhbABEr1WSBQgjAQEBAQEICQsJFCeCIAEBAQQSAhMZARsSDAMMBgULDQ0hIQEBEQEFAQoSBgESCAoQh08BAw8LngIJA4wogWyBCoUaChknAwpZiHUBBQyKY2mGbwOSP4FdgVWBF4oSgy8WKYQT X-IronPort-AV: E=Sophos;i="4.80,634,1344204000"; d="scan'208";a="178473009" Received: from mail-ie0-f182.google.com ([209.85.223.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 23 Oct 2012 09:57:00 +0200 Received: by mail-ie0-f182.google.com with SMTP id k10so8694609iea.27 for ; Tue, 23 Oct 2012 00:57:00 -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 :content-type:content-transfer-encoding; bh=4U9OUxwW9YNS1dcupDvA6jouSJunNPLye84di4kVEiI=; b=CBa1D16W512aocvPKtJTA+o6E0Dq/buCnHUq1/XuvOYt++SGINNolVA2uTwG3k8lo5 we6i8TnmuUTfMr7t2AT71KV3T/I/w2RXcG5CHihR8pePgIRi022QeFMwQGhEEp/9FmDM 84LwGwvY2sCAbwi/8VgrvaUz56Q/m2cOTIEXAD2vhuaxg8rbsr2ZUGtzAsWR85/L3xHq kWZDkFXwMfeetp0ze++TpekFutU0xI9+ayG7bD8WIAMaCQ0LuWJJ7d2wGGnqKwh8fRRd pUQq63wA0OCdk1xJFGq2rNnU5yiF+pUOuQsfn1NQoRqq+56gCquUHvJ8TnbTsD8sC7wj PH+A== Received: by 10.50.1.170 with SMTP id 10mr11829224ign.2.1350979020286; Tue, 23 Oct 2012 00:57:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.65.9 with HTTP; Tue, 23 Oct 2012 00:56:20 -0700 (PDT) In-Reply-To: References: From: Gabriel Scherer Date: Tue, 23 Oct 2012 09:56:20 +0200 Message-ID: To: Philippe Veber , caml users Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Parameterizing a function with a thread monad If you want to parametrize over arbitrary monads, the modularized appraoch (using functors or first-class modules) is adapted. But note that for more specialized needs different interfaces are possible. For example, Daniel B=FCnzli experimented with explicit inversion of control instead of parametrization by monadic library, to solve the problem of being Lwt/Async/"event loop" agnostic: [Caml-list] Non-blocking IO interface design https://sympa.inria.fr/sympa/arc/caml-list/2012-04/msg00055.html I'm not sure how this worked out in the end, but this may be worth looking at if you're still at the general design step. On Tue, Oct 23, 2012 at 1:52 AM, Jeremy Yallop wrote: > On 22 October 2012 23:09, Philippe Veber wrote: >> A couple of libraries, like pgocaml for instance, define a functor over a >> (monadic) thread implementation, like in the following: >> >> module type Thread =3D sig >> type 'a t >> val return : 'a -> 'a t >> val bind : 'a t -> ('a -> 'b t) -> 'b t >> end >> >> module F(T : Thread) : sig >> val v : string -> string T.t >> end >> >> Is it possible to define F as a function (ie at the value level)? > > Yes! Mat=EDas Giovannini has a blog post showing how to do just that: > > http://alaska-kamtchatka.blogspot.co.uk/2011/09/higher-order-fun.html > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs