From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id A2C8CBC37 for ; Thu, 11 Feb 2010 11:39:12 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: At8CAE9tc0vRVdvdamdsb2JhbACRIolQCBUNBgMMBxMDIK0lgUiEZYhyAQEDBYRRBA X-IronPort-AV: E=Sophos;i="4.49,450,1262559600"; d="scan'208";a="52551261" Received: from mail-ew0-f221.google.com ([209.85.219.221]) by mail1-smtp-roc.national.inria.fr with ESMTP; 11 Feb 2010 11:39:12 +0100 Received: by ewy21 with SMTP id 21so1248000ewy.22 for ; Thu, 11 Feb 2010 02:39:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=9Q/vHC98IjyLf0aRaFMM+b+D3zG5urcyqNc8x5WxOpo=; b=gOlPLlAspZ7IXUelRWk54lKchQoT4+ulyrfW4Q6hmOyWPvR5Ks4ovL4gq4qcvEuc0U QN4dlI7Xbt4ZNvPLKQb/cN/Nt8rVPWOw4jOX40GE+I8i/LY24rH6+YNFFSw5y8aeQCqc qTnay5bcISePj2OrhSxs1DA8twpsMoxo3IOlo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=rwy+KSewYv891V7TaWDW1QZb5cMJzfSmTCeOlDKAkbDEYdI6a2/yx0rDwHdHD2nfci ziIsd3JII5D/8koAn6BtAo1gJKzAAzlOvBuNCXkgO69cNmS4MNjAYbouQkcaiZlQtt6x btXTYIJiRc2imNpDtt+5icEqkIXkw6XBYYtd8= MIME-Version: 1.0 Received: by 10.213.104.88 with SMTP id n24mr440028ebo.22.1265884747162; Thu, 11 Feb 2010 02:39:07 -0800 (PST) In-Reply-To: <891bd3391002081959i4f9b70d4re1914ad7e439b5e3@mail.gmail.com> References: <14cf844b1002081907y2900c313q97ae0cb6f4c92394@mail.gmail.com> <891bd3391002081959i4f9b70d4re1914ad7e439b5e3@mail.gmail.com> Date: Thu, 11 Feb 2010 11:39:07 +0100 Message-ID: <4b39c80a1002110239i2fc1f555if642ed6a589d5b66@mail.gmail.com> Subject: Re: [Caml-list] Preventing values from escaping a context From: Alexey Rodriguez To: yminsky@gmail.com Cc: Rich Neswold , Inria Ocaml Mailing List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; yaron:01 minsky:01 yminsky:01 monads:01 monads:01 ocaml:01 ocaml:01 haskell:01 compilation:01 haskell:01 compiler:01 compilation:01 cheers:01 guideline:98 inspected:98 On Tue, Feb 9, 2010 at 4:59 AM, Yaron Minsky wrote: > > I don't know that monads solve your problem here, but monads are a perfec= tly > reasonable idiom in OCaml.=A0 You won't find them in the standard library > because the standard library is very conservative.=A0 But you will find t= hem > in Jane Street's Core library, and we use them reasonably often.=A0 I thi= nk > there's no reason to avoid monads in OCaml (although obviously there's no= t > much to be gained by using them for vanilla effects, as is done in Haskel= l.) This is interesting. We have been considering using monads where I work but we worry about possible performance problems. Have you experienced reduced performance? Also, do you have a guideline on when to use them? We are thinking of using monads in a DSL, but only to build values (think of some kind of compilation) that can later be efficiently inspected. On whether monads can solve the problem in this thread, yes they can. But for this you need support from the type system (rank-2 universal quantification). This is what Haskell does with the ST monad. The compiler detects the value leak and aborts compilation with a type error. If you are interested in a reference I can dig it up later. Cheers, Alexey