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 12CBA7EC41 for ; Wed, 24 Oct 2012 12:31:09 +0200 (CEST) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of philippe.veber@gmail.com) identity=pra; client-ip=209.85.220.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="philippe.veber@gmail.com"; x-sender="philippe.veber@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.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=mail1-smtp-roc.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 (mail1-smtp-roc.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=mail1-smtp-roc.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: ArABADjDh1DRVdw2m2dsb2JhbABEsBqRWggjAQEBAQEICQsdJ4IeAQEBAwESAhMZARsdAQMBCwYFBAcNLiEBAREBBQEcBhMih08BAwkGC5xOCQOMKIJ2hG0KGScNWYh1AQUMim1nhmsDkkGBXYFViymDLxYphBM X-IronPort-AV: E=Sophos;i="4.80,639,1344204000"; d="scan'208";a="178704961" Received: from mail-pa0-f54.google.com ([209.85.220.54]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 24 Oct 2012 12:30:59 +0200 Received: by mail-pa0-f54.google.com with SMTP id bi1so341785pad.27 for ; Wed, 24 Oct 2012 03:30:57 -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=1O5HhkU0pvnt5mCKI0ghKv+TjNbe0ic2QlSFeP2vNQo=; b=Ej6B6zYkh/V/5JCQpJevsunjSmlO5VQgLDjhbTJ85Ade82M6iZGHA6XLo0H4Kzi62i 5hQw8nS54q3ogKdixbZZwQsqpin8jGtwnfHFb7q+yZDQintKrt52Py6K4hC+7jpnYH7D uyay8WBFJj3sJNUu0KYENYp3gf79sxXEsiZhDqF8lDJixABewrxWUqkxtq2elDjgv28v DCo21sTad+tNkmyhXM+3xtaYoJAZKLwOWmY6MV4R5Yj18FlMGJ7yiVOPOBtrIuNwVYJZ /Ua3sNOAM3zvfNf7Er6sYMCU5KBX7rHTp5qI54+AH9AsB+QOYU/XyFtYcZ9iEGAqk80A uceg== Received: by 10.68.125.230 with SMTP id mt6mr48695287pbb.110.1351074657637; Wed, 24 Oct 2012 03:30:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.66.241.169 with HTTP; Wed, 24 Oct 2012 03:30:37 -0700 (PDT) In-Reply-To: References: From: Philippe Veber Date: Wed, 24 Oct 2012 12:30:37 +0200 Message-ID: To: Jeremy Yallop Cc: caml users Content-Type: multipart/alternative; boundary=047d7b2e44460894a604cccb95d7 X-Validation-by: philippe.veber@gmail.com Subject: Re: [Caml-list] Parameterizing a function with a thread monad --047d7b2e44460894a604cccb95d7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 2012/10/23 Jeremy Yallop > 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 > Thanks a lot Jeremy, this is indeed exactly what I was looking for! I suppose this (clever) representation has a cost at run-time. Maybe it'd be worth to investigate it, as a typical monadic computation will use a lot of bind/return operations. I'll try to have a look at it. Thanks again! --047d7b2e44460894a604cccb95d7 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

2012/10/23 Jeremy Yallop <yallop@gmail.c= om>
On 22 October 2012 23:09, Philippe = Veber <philippe.veber@gmail.= com> wrote:
> A couple of libraries, like pgocaml for instance, define a functor ove= r 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)?

Yes! =A0Mat=EDas Giovannini has a blog post showing how to do j= ust that:

http://alaska-kamtchatka.blogspot.co.uk/2011/09/hi= gher-order-fun.html

Thanks a lot Jeremy, this is indeed exactly what I w= as looking for! I suppose this (clever) representation has a cost at run-ti= me. Maybe it'd be worth to investigate it, as a typical monadic computa= tion will use a lot of bind/return operations. I'll try to have a look = at it. Thanks again!


--047d7b2e44460894a604cccb95d7--