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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id D27F57FD3B for ; Sat, 21 Nov 2015 21:37:45 +0100 (CET) IronPort-PHdr: 9a23:Q/iZkxyKzoJPel7XCy+O+j09IxM/srCxBDY+r6Qd0eITIJqq85mqBkHD//Il1AaPBtWGrawbwLOP6ejJYi8p39WoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6kO74TNaIBjjLw09fr2zQd6PyZronLnrodX6WEZhunmUWftKNhK4rAHc5IE9oLBJDeIP8CbPuWZCYO9MxGlldhq5lhf44dqsrtY4q3wD89pozcNLUL37cqIkVvQYSW1+ayFm0vb2rgHORhej4X4VU2Ne0kYZQluN0BavZIr3siL8uaJZ2WHOJ9DwTbkyVhy66Lx3RRiujiobYW0X6mbS3+53iqtA6DCsoQdyxcaAYoO9NeFlY76bdtQfEzkSFv1NXjBMV9vvJ7AECPAMaKMF9oQ= Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jj@issuu.com; spf=Pass smtp.mailfrom=jj@issuu.com; spf=None smtp.helo=postmaster@mail-lf0-f47.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of jj@issuu.com) identity=pra; client-ip=209.85.215.47; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jj@issuu.com"; x-sender="jj@issuu.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of jj@issuu.com designates 209.85.215.47 as permitted sender) identity=mailfrom; client-ip=209.85.215.47; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jj@issuu.com"; x-sender="jj@issuu.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-lf0-f47.google.com) identity=helo; client-ip=209.85.215.47; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jj@issuu.com"; x-sender="postmaster@mail-lf0-f47.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CsAAAS1VBWmy/XVdFehA5vBq8sjUWEDSOFbAKBKQc8EAEBAQEBAQEBEAEBAQEBBgsLCSEugi2CCAEBBBIRBBkBASwLAQ8LCw0CAgkdAgIiEgEFAQoSBhMSEId3AxINoWaBMT4xildxhGMBBYYAA4R5AQEBAQEFAQEBAQEBFwYKd4VThH6CcYFogxyBRIYTDIcEiTKFJIgNgVtJljWCJRIkgRc4gi8jgV49NIUrAQEB X-IPAS-Result: A0CsAAAS1VBWmy/XVdFehA5vBq8sjUWEDSOFbAKBKQc8EAEBAQEBAQEBEAEBAQEBBgsLCSEugi2CCAEBBBIRBBkBASwLAQ8LCw0CAgkdAgIiEgEFAQoSBhMSEId3AxINoWaBMT4xildxhGMBBYYAA4R5AQEBAQEFAQEBAQEBFwYKd4VThH6CcYFogxyBRIYTDIcEiTKFJIgNgVtJljWCJRIkgRc4gi8jgV49NIUrAQEB X-IronPort-AV: E=Sophos;i="5.20,329,1444687200"; d="scan'208";a="188543527" Received: from mail-lf0-f47.google.com ([209.85.215.47]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 21 Nov 2015 21:37:44 +0100 Received: by lffu14 with SMTP id u14so87805728lff.1 for ; Sat, 21 Nov 2015 12:37:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=issuu.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=loFzKGR4fodORM7Q5don5SSIhS8ZIPsZtTtarN+RtP0=; b=UntYjS7j1v68Qbt4KUjVkL7UfEilq7vVPxLeOJ3ANvDxqcCoWOy//RWsoxOfxsQ7dq 1OGQP91l9aPkicTRpFPIT2F5liS65j4Uk+z1fPEcRNU765f7sqYEVAtciQlc71PVLE10 S80QKdRmkwV1wxSD+31MIRECiWSmrLxXX8a48= 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:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=loFzKGR4fodORM7Q5don5SSIhS8ZIPsZtTtarN+RtP0=; b=EVE67TriA5drcmPhlCYi9twr0liiB8ac/pxOGxxJ9DVRGjk6xtgNCxVRH2Gu/E8Ny+ UwYz8mMuDf/C9QmTwZII5E0UGTvwds7qMgenddY9HbNNpugsdDEErNzjgv67tCV0QEgC diw0ILQFVhUFGo1noKTN8H9UKN3u6cZGBiZlOFlOE+sfkV2ygKUsFN+nl9u/FsngTfUS RtQkZJW9sArK9ESX2lNc1cHvxvJKVkdYY6AYFVJ5P/52kUz8sM+tmIccqa9yJU4aEnqq T/xImd09ZmhJVZK7JHLRx4JZfV67EFX5nncIp5shHB2/WZzMOSxpmMbjAYAHWVP044QU JZaA== X-Gm-Message-State: ALoCoQkBlKrJf8tZnaHHtid2XFp88/F3vqufPIqMjTU7IQs7TiUYpT5ZsimWUibB35WiEgoolK3b MIME-Version: 1.0 X-Received: by 10.25.42.20 with SMTP id q20mr7236296lfq.158.1448138263796; Sat, 21 Nov 2015 12:37:43 -0800 (PST) Received: by 10.25.201.8 with HTTP; Sat, 21 Nov 2015 12:37:43 -0800 (PST) In-Reply-To: References: Date: Sat, 21 Nov 2015 21:37:43 +0100 Message-ID: From: Jonas Jensen To: Runhang Li Cc: Ocaml Mailing List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] GADT and weak polymorphism I was asked the same question and found the following stackoverflow discussion in which two possible remedies are suggested: http://stackoverflow.com/questions/25025091/ocaml-formatters-and-value-rest= riction. Jeffrey Scofield suggests changing your ``l`` to let l () =3D '2' **> "str" **> empty Leo White suggests writing ``l`` so that it's a value rather than an expression. In your case, you'd write: module HList =3D struct type (_, _) hlist =3D | Empty : ('a, 'a) hlist | :: : 'c * ('a, 'b) hlist -> ('c -> 'a, 'b) hlist let empty =3D Empty let l =3D '2' :: "str" :: empty end I believe that ``::`` is the only infix constructor name in OCaml, so you have to shadow standard list cons in the module of hlist to make this work. In the new ocaml-amqp library, we chose the latter remedy. See the full result here: https://github.com/andersfugmann/ocaml-amqp/blob/790486dad/src/amqp_protoco= l.ml#L197 Cheers, Jonas On 17 November 2015 at 19:14, Runhang Li wrote: > Hi, camels > > Consider the following module: > > module HList =3D struct > > type (_, _) hlist =3D > | Empty : ('a, 'a) hlist > | Cons : 'c * ('a, 'b) hlist -> ('c -> 'a, 'b) hlist > > let cons : type a b c. c -> (a, b) hlist -> (c -> a, b) hlist =3D > fun h tl -> Cons (h, tl) > > let empty =3D Empty > > let ( **> ) =3D cons > > let l =3D '2' **> "str" **> empty > > end > > The type of ``l`` is ``(char -> string -> =E2=80=98_a, =E2=80=98_a) hlist= ``. I would like to know the reason that weak polymorphism shows up here. > > Thank you > > > Kindly, > > Runhang > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs