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 DDA357FFA2 for ; Tue, 8 Mar 2016 07:00:17 +0100 (CET) IronPort-PHdr: 9a23:iSIiNxHSK07TtBqW3QKD551GYnF86YWxBRYc798ds5kLTJ75oMSwAkXT6L1XgUPTWs2DsrQf27WQ4/qrCT1IyK3CmU5BWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYsExnyfTB4Ov7yUtaLyZ/niKbiodaDMk1hv3mUX/BbFF2OtwLft80b08NJC50a7V/3mEZOYPlc3mhyJFiezF7W78a0+4N/oWwL46pyv+YJa6jxfrw5QLpEF3xmdjltvIy4/SXEGDqI+nIZGk8fiBxPEkCR/RbmV5L7uzH8sftV1yyTPMmwRrcxD2eM9aBuHTrpjC4BAAUl+WfQiMFujakT9BegoxV52JL8b4ScNf44daTYK4BJDVFdV9pcAnQSSri3aJECWq9YZb5V Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=milanst@gmail.com; spf=Pass smtp.mailfrom=milanst@gmail.com; spf=None smtp.helo=postmaster@mail-io0-f176.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of milanst@gmail.com) identity=pra; client-ip=209.85.223.176; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="milanst@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of milanst@gmail.com designates 209.85.223.176 as permitted sender) identity=mailfrom; client-ip=209.85.223.176; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="milanst@gmail.com"; 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@mail-io0-f176.google.com) identity=helo; client-ip=209.85.223.176; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="postmaster@mail-io0-f176.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0B2AQBmad5WlbDfVdFchHkGqEWHHYxXhg8CgS4HOxEBAQEBAQEBARABAQEBBwsLCSEvgi2CFQEBAwESER0BGx0BAwELBgULDwImAgIiAREBBQEcBjWHbAEDCgihSIExPjGLNoFqgleFWgoZJw1Rg3MBAQEBAQUBAQEBARUBBQoEbYUchD2HOoE6BY4kiQaNbo56jRgRHoEPNoIiHoFuHi6JfwEBAQ X-IPAS-Result: A0B2AQBmad5WlbDfVdFchHkGqEWHHYxXhg8CgS4HOxEBAQEBAQEBARABAQEBBwsLCSEvgi2CFQEBAwESER0BGx0BAwELBgULDwImAgIiAREBBQEcBjWHbAEDCgihSIExPjGLNoFqgleFWgoZJw1Rg3MBAQEBAQUBAQEBARUBBQoEbYUchD2HOoE6BY4kiQaNbo56jRgRHoEPNoIiHoFuHi6JfwEBAQ X-IronPort-AV: E=Sophos;i="5.22,555,1449529200"; d="scan'208";a="167552897" Received: from mail-io0-f176.google.com ([209.85.223.176]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 08 Mar 2016 07:00:16 +0100 Received: by mail-io0-f176.google.com with SMTP id g203so14673877iof.2 for ; Mon, 07 Mar 2016 22:00:16 -0800 (PST) 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; bh=jOQvkMPFx1ccii0uqeP/5nqLvzKAb/TBdmmXvNqcly8=; b=Z2soZUiEhHZ7xiAIcLf8JeW/bDk+oRr6um2szsU7Ynz21AeUss663fN4Ym5Jn/iPH4 98n8zEl3D1wiJCjdnCpVCxO7dK9S0Vy2OA9btMSAMBy+JxePFhn/3UIR+5EOaUntWy8w iRzfTfyVBxsiZJ87vAx5ovoa3qo9atWGp9G9d/GTNRPtGhhQEHJ0V2TSTu6+LcuTDCoW wEIpS6scbJfJu6AcvqKnSDVHmHWOp2rWTx6iDtnzHbVl+ChQywiHpUk9HzcRMCn3PnQg WL53gheWY0f4uoUpJt9QIhQ7SaZMb3hxiLLjR7/shW3ZnbeMMJPo2NkO1YIKV5WYXpNF XSoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=jOQvkMPFx1ccii0uqeP/5nqLvzKAb/TBdmmXvNqcly8=; b=Hzz9GXVudMBzOeE0T/nSxgzeYN+IG059lVoMwpMaUONs0QxTw6k4sQvOmoIozT7dWH Y76XHqSqvzZwrUsd5mfr/T377gLFuoOQ1WGb+/jg9OfR5DB8zSwIszQholaRabS2oKNE nI7XcVhzp9fihdVGxrNG2azp3M9y8PJazq+H/9PPXHwqfO0SIW/JABLhyySxanqmlu+O yTqybghaXLeyi9qeiHVlOJnkja4sdXi4aJzlhmBL5JG8b3+02KXt9hIw3bcazrBILRqU scVy/1w6vGSoX2uNWa0Wkrjw5d3yruNrKyRnxCxszjAUyqLj8cqtlQ6DTUDejKBKPh/z OvtQ== X-Gm-Message-State: AD7BkJK9pQUT6qXPFeCdMG8K12kQMoxvXrkiJfod7i1QFJtuXoDTgrTLdaBXemymiNZWVnFJLSZEwru90SrXDA== X-Received: by 10.107.166.195 with SMTP id p186mr24885805ioe.146.1457416815495; Mon, 07 Mar 2016 22:00:15 -0800 (PST) MIME-Version: 1.0 Received: by 10.79.123.22 with HTTP; Mon, 7 Mar 2016 21:59:36 -0800 (PST) In-Reply-To: References: From: =?UTF-8?Q?Milan_Stanojevi=C4=87?= Date: Tue, 8 Mar 2016 00:59:36 -0500 Message-ID: To: Yotam Barnoy Cc: Ocaml Mailing List Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] Question about Lwt/Async > One of the advantages of OCaml over Haskell (which I'm not crazy about) is > the fact that you don't have to constantly be stuck inside a monad. However, > once you want to use these user-level threading libraries, you're > essentially tied to a monad. It also means that the usage of any other monad > from Lwt/Async code is out -- OCaml doesn't have the monad transformer > infrastructure to layer monads easily as far as I can tell (am I wrong?). I > mean, even in Haskell using Monad Transformers is a pain (IMO). Are there any particular monads you have in mind? My experience is that it's not a big problem in practice with Async (I don't have experience with lwt but I guess it is similar) but I don't really use a lot of monads (mostly just Deferred and Or_error) With async, a good programming style is to keep asynchronous code at the fringes of your application and make as much of your program's logic synchronous. This is good for performance but more importantly makes your code easier to reason about because you don't have to worry about any interleaving and races since async runs code without binds and maps as an atomic job. This means that large parts of your code are just usual synchronous ocaml code (you might not even open Async in a module) and you are free to easily use any monad you want. Of course, there are cases when you will run into issues, usually combining Or_error and Deferred monads. Common case is when handling rpcs in async. There indeed you are stuck for a bit in Deferrred.Or_error monad but at some point you need to handle two cases (Error and Ok) and you escape it.