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 8595F7F61E for ; Wed, 1 Nov 2017 08:11:28 +0100 (CET) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=oleg@okmij.org; spf=Pass smtp.mailfrom=oleg@okmij.org; spf=None smtp.helo=postmaster@mail1.g3.pair.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of oleg@okmij.org) identity=pra; client-ip=66.39.3.114; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="oleg@okmij.org"; x-sender="oleg@okmij.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of oleg@okmij.org designates 66.39.3.114 as permitted sender) identity=mailfrom; client-ip=66.39.3.114; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="oleg@okmij.org"; x-sender="oleg@okmij.org"; 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@mail1.g3.pair.com) identity=helo; client-ip=66.39.3.114; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="oleg@okmij.org"; x-sender="postmaster@mail1.g3.pair.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AhdScOhLi0/tWZ1naPtmcpTZWNBhigK39O0sv0rFi?= =?us-ascii?q?tYgXLvXxwZ3uMQTl6Ol3ixeRBMOAtKIC1rKempujcFJDyK7JiGoFfp1IWk1Nou?= =?us-ascii?q?QttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBWB6kG1uCYSGxH+LRJ4?= =?us-ascii?q?YPr4EIPIp8uy3uG2vZbUZlZmnj24NJR2IRr++QLVu8Y+hohnK6R3zQHG9CgbM9?= =?us-ascii?q?9KzH9lcArA1y334d29qcZu?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0DGAQD1cvlZh3IDJ0JcHAEBBAEBCgEBF?= =?us-ascii?q?wEBBAEBCgEBhBhuJ48PjiSBfJhTCiOEAwGBFAKEdkIVAQEBAQEBAQEBAQESAQE?= =?us-ascii?q?BCA0JCCgvgjgigkQBAgIBJxM/BRYhNAWKdwgQqXs6iwsBAQgBAQEBJIMuggeBU?= =?us-ascii?q?oUUgxYMgVligniCMgWSbY8ZgxiETo0JDYJzgROPKIxfiTOBOTWCDVUyCEmCVAE?= =?us-ascii?q?PCYJjggJoAYxfAQEB?= X-IPAS-Result: =?us-ascii?q?A0DGAQD1cvlZh3IDJ0JcHAEBBAEBCgEBFwEBBAEBCgEBhBh?= =?us-ascii?q?uJ48PjiSBfJhTCiOEAwGBFAKEdkIVAQEBAQEBAQEBAQESAQEBCA0JCCgvgjgig?= =?us-ascii?q?kQBAgIBJxM/BRYhNAWKdwgQqXs6iwsBAQgBAQEBJIMuggeBUoUUgxYMgVligni?= =?us-ascii?q?CMgWSbY8ZgxiETo0JDYJzgROPKIxfiTOBOTWCDVUyCEmCVAEPCYJjggJoAYxfA?= =?us-ascii?q?QEB?= X-IronPort-AV: E=Sophos;i="5.44,327,1505772000"; d="scan'208";a="243052098" Received: from mail1.g3.pair.com ([66.39.3.114]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Nov 2017 08:11:27 +0100 Received: from mail1.g3.pair.com (localhost [127.0.0.1]) by mail1.g3.pair.com (Postfix) with ESMTP id 211863FB8FE; Wed, 1 Nov 2017 03:11:24 -0400 (EDT) Received: from Magus.localnet (g.sf.ecei.tohoku.ac.jp [130.34.192.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail1.g3.pair.com (Postfix) with ESMTPSA id C2E2C582CFA; Wed, 1 Nov 2017 03:11:21 -0400 (EDT) Date: Wed, 1 Nov 2017 16:16:09 +0900 From: Oleg To: philippe.veber@gmail.com Cc: caml-list@inria.fr, rich@annexia.org, nick.palladinos@gmail.com Message-ID: <20171101071609.GA1448@Magus.localnet> Mail-Followup-To: Oleg , philippe.veber@gmail.com, caml-list@inria.fr, rich@annexia.org, nick.palladinos@gmail.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) Subject: Re: [Caml-list] What if exn was not an open type? > I thought one big selling argument of monads was also that the type of > the functions shows which effect it performs. As I understand it, it > is not the case for effects, at least not in existing implementations > like multicore ocaml. ... Also, would you know a reference that shows > that effects compose indeed a lot more easily than monads? How expressive are the types of effectful computations pretty much depends on a particular type system in use. Let me cite from the message that I received from Nick Palladinos (CCed) the other week, who implemented extensible effects in F#, a rather close relative of OCaml. You can write the code as below let example () = eff { do! put 1 let! x = get () let! y = ask () return x + y } (Here, `eff' is a tag of so-called computational expressions of F#, a very handy feature). The *inferred* type is as follows val example : unit -> Eff<'U,int> when 'U :> Reader and 'U :> State clearly stating that example is an effectful expression that uses at least Reader and State effects. The example also illustrates composability, your second question: put/get and ask are operations of two distinct effects (State and Reader, resp). You can combine them freely within the same program. (I hope Nick will write a paper explaining his implementation so that we can all learn from it.) To give more references (in addition to Leo's work), I should point to Koka https://koka-lang.github.io/koka/doc/kokaspec.html which is an OCaml-like language based on effects and effect-typing. The language is mature enough to write a web server in it (as Daan Leijen described in his talk at the ML Family workshop this year). Other references are the recent Effekt library in Scala http://b-studios.de/scala-effekt/ and extensible-effect library http://okmij.org/ftp/Haskell/extensible/ which, although being first proposed for Haskell has also been ported to Scala (and now F#). Purescript's extensible effects are also similar.