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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 7B27E7EC41 for ; Wed, 24 Oct 2012 12:46:06 +0200 (CEST) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of philippe.veber@gmail.com) identity=pra; client-ip=209.85.220.54; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="philippe.veber@gmail.com"; x-sender="philippe.veber@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of philippe.veber@gmail.com designates 209.85.220.54 as permitted sender) identity=mailfrom; client-ip=209.85.220.54; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="philippe.veber@gmail.com"; x-sender="philippe.veber@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-pa0-f54.google.com) identity=helo; client-ip=209.85.220.54; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="philippe.veber@gmail.com"; x-sender="postmaster@mail-pa0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArEBAIrGh1DRVdw2m2dsb2JhbABEr2cziHMBiGYIIwEBAQEBCAkLHSeCHgEBAQMBEgITGQEbEgsBAwELBgUEBw0NISEBAREBBQEKEgYTEgkHh08BAwkGC5xRCQOMKIJ2hHAKGScDClmIdQEFDIptZ4ZrA5JBgV2BVYEXihKDLxYphBM X-IronPort-AV: E=Sophos;i="4.80,639,1344204000"; d="scan'208";a="160222075" Received: from mail-pa0-f54.google.com ([209.85.220.54]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 24 Oct 2012 12:45:59 +0200 Received: by mail-pa0-f54.google.com with SMTP id bi1so350816pad.27 for ; Wed, 24 Oct 2012 03:45:58 -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 :cc:content-type; bh=pAqTf2jFRgvGT4/29aG5ikEEqwIxpunOhmtwN+ry7lc=; b=lBydPORiOx7q0xorjvOR7+jdEEt1wDlTMTS4kB8cNxSs5QWCsjgufu2WDv+ns9RnhO twStJu5ytnm2rEeXm3z0CIgWSHsr3B6uLETpbp5QjL7auDIruzKvwCvrrpCQDx4KAfzq Yzl9cyOKCyMkd1NoxDy7UroEGTg9I30EAsG67QXmY4XLMIoAR5d+IFJjaBiNY5YWF3v8 geU1Qa+qhrGpB06i5TE9wpg+DbIGekb2ipGCxJImLi+Sh0DM0hAblSA25qGmEqRmm/rU B42quOB3WQ2UL4IkFI+94DI+zxeixAsDIS6tGaOzW8zMX5XAFC0owXb1OZwKWPVtogeN vXQA== Received: by 10.68.125.230 with SMTP id mt6mr48794902pbb.110.1351075558038; Wed, 24 Oct 2012 03:45:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.66.241.169 with HTTP; Wed, 24 Oct 2012 03:45:37 -0700 (PDT) In-Reply-To: References: From: Philippe Veber Date: Wed, 24 Oct 2012 12:45:37 +0200 Message-ID: To: Gabriel Scherer Cc: caml users Content-Type: multipart/alternative; boundary=047d7b2e4446b39e8e04cccbcae2 X-Validation-by: philippe.veber@gmail.com Subject: Re: [Caml-list] Parameterizing a function with a thread monad --047d7b2e4446b39e8e04cccbcae2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Gabriel, well thanks, I had forgotten this interesting approach by Daniel. Indeed for now I'd like to try a functor/first-class module -based solution. Thanks for the suggestion anyway! Cheers, ph. 2012/10/23 Gabriel Scherer > 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 > --047d7b2e4446b39e8e04cccbcae2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Gabriel,

well thanks, I had forgotten this interesting approach = by Daniel. Indeed for now I'd like to try a functor/first-class module = -based solution. Thanks for the suggestion anyway!
Cheers,
=A0 ph.

2012/10/23 Gabriel Scherer <gabriel= .scherer@gmail.com>
If you want to parametrize over arbitrary mo= nads, 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:

=A0 [Caml-list] Non-blocking IO interface design
=A0 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 <yallop@gmail.com> wrote:
> On 22 October 2012 23:09, Philippe Veber <philippe.veber@gmail.com> 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
>> =A0 type 'a t
>> =A0 val return : 'a -> 'a t
>> =A0 val bind : 'a t -> ('a -> 'b t) -> 'b= t
>> end
>>
>> module F(T : Thread) : sig
>> =A0 val v : string -> string T.t
>> end
>>
>> Is it possible to define F as a function (ie at the value level)?<= br> >
> Yes! =A0Mat=EDas Giovannini has a blog post showing how to do just tha= t:
>
> http://alaska-kamtchatka.blogspot.co.uk/2011/= 09/higher-order-fun.html
>
> --
> Caml-list mailing list. =A0Subscription 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

--047d7b2e4446b39e8e04cccbcae2--