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 1553F7F30D for ; Wed, 9 Jan 2013 15:15:07 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of krismicinski@gmail.com) identity=pra; client-ip=209.85.214.170; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="krismicinski@gmail.com"; x-sender="krismicinski@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of krismicinski@gmail.com designates 209.85.214.170 as permitted sender) identity=mailfrom; client-ip=209.85.214.170; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="krismicinski@gmail.com"; x-sender="krismicinski@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-ob0-f170.google.com) identity=helo; client-ip=209.85.214.170; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="krismicinski@gmail.com"; x-sender="postmaster@mail-ob0-f170.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhICACB67VDRVdaqk2dsb2JhbABEvUoIFg4BAQEBCQkLCRQEI4IeAQEFQAEbDw4BAwwGBQsNLiIBEQEFARwGE4gEAQMPDJpHjDOCe4R4ChknDVmFYAEFDJEEA4hhjSuBHI1MFimENA X-IronPort-AV: E=Sophos;i="4.84,438,1355094000"; d="scan'208";a="189105605" Received: from mail-ob0-f170.google.com ([209.85.214.170]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 09 Jan 2013 15:15:06 +0100 Received: by mail-ob0-f170.google.com with SMTP id wp18so2236580obc.15 for ; Wed, 09 Jan 2013 06:15:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=NyGj4XCd7BV0PWYoMa1675yB2fom2puum7F6+uRxGlY=; b=zeVMEKMCtJrtKiEXMPX6UVEwdYYSPfxDQjtU9+7DdAktG52tPCOwTCWzXfW9/RTGz8 Dk/5WObxjD6X5sv7w50aeuWQyKB2o82+NuAVVzE0LBFvvFcH7d9r9dcnqezn7FE/maJG xhPZsnYNI4ZOe1qc+wMWtbHPvsEzhU+fIlVTrxxiBw/x/cKcaksyWx3APDMfSBjVa3Vt MStq/aIM6h40QHMVqv6w2t+5ylodXzdZ71l1l1iP361kzT7F//0gf0Nc4bZomuNDOu0e EZ+lGWRr/mrdKcVfb/b62zkt8tI0KjRkPbmr5i5rmxlA/a1W2SYcpmFZhKeK30ZWsTsW sYCA== MIME-Version: 1.0 Received: by 10.182.194.70 with SMTP id hu6mr48910002obc.4.1357740904885; Wed, 09 Jan 2013 06:15:04 -0800 (PST) Received: by 10.182.89.6 with HTTP; Wed, 9 Jan 2013 06:15:04 -0800 (PST) In-Reply-To: References: <50ECE88D.9000905@riken.jp> Date: Wed, 9 Jan 2013 09:15:04 -0500 Message-ID: From: Kristopher Micinski To: David MENTRE Cc: Francois Berenger , caml-list Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] some beautiful OCaml code On Wed, Jan 9, 2013 at 3:38 AM, David MENTRE wrote: > Hello OCaml experts, > > 2013/1/9 Francois Berenger : > I never fully grasped polymorphic variants compared to regular ones > but I always had the feeling the polymorphic variants where less safe > that variants because they would allow more possibility to mix > unrelated things[1]. > I would say that it's not that polymorphic variants are less safe, but they can occasionally be more painful, because of the explicit type signatures, and because of type inference you can end up with some ugly errors. It's typically recommended that when you use polymorphic variants you use explicit annotations. I suppose they could be unsafe if, say, you had two similarly named constructors with the same signature that had different semantics between different modules. But that would probably be bad style to begin with. There's a StackOverflow guide on when to use polymorphic variants, I agree with the answer: http://stackoverflow.com/questions/9367181/variants-or-polymorphic-variants Kris