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 097D17FE36 for ; Fri, 3 Jun 2016 17:50:19 +0200 (CEST) IronPort-PHdr: 9a23:L6wmQBLlNzTq4W0wkNmcpTZWNBhigK39O0sv0rFitYgVKv7xwZ3uMQTl6Ol3ixeRBMOAu6MC1bGd4vqocFdDyKjCmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBybrysXNWC3oLpjKvjodX6WEZhunmUWftKNhK4rAHc5IE9oLBJDeIP8CbPuWZCYO9MxGlldhq5lhf44dqsrtY4q3wD89pozcNLUL37cqIkVvQYSW1+ayFm0vb2rgHORhej4X4VU2Ne0kYZQluN0BavFLz4qCbmquc5kAuTNtTrQKt+EWCp5r1mVAPloCIMMjci7GzNzMd52vF1uhWk8i122YnSKKSUMuF9b+uJbNYbQ3FCT+5TXipMGZ+mYoYTSeEGOLAL/MHGu1ISoE7mVkGXD+T1x2oN2yb7 Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=yminsky@janestreet.com; spf=Pass smtp.mailfrom=yminsky@janestreet.com; spf=None smtp.helo=postmaster@mxout3.mail.janestreet.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of yminsky@janestreet.com) identity=pra; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="yminsky@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of yminsky@janestreet.com designates 38.105.200.229 as permitted sender) identity=mailfrom; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="yminsky@janestreet.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@mxout3.mail.janestreet.com) identity=helo; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="postmaster@mxout3.mail.janestreet.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0D1AQAOplFXc+XIaSZchBB9BqlOKotfhH2BeSKFcAKBMAc4FAEBAQEBAQEBEQEKFglQgjCCFQEBAQMBEhEEGQEBLAsBBAsJAgsGBAEBAQ0dAgIiEgEFAQoKCAYTEhCHcwMPCAMLlAyPQoExPjGKVGeEQQEBBYg/A4QpAQEBAQEBAQEBAQEBAQEBAQEBAQEBFAgQhheETYRtglSCWQGGRgyRd4YDiCGBaU6HLYU4jhMSHoEPDw+CMIIQUooSAQEB X-IPAS-Result: A0D1AQAOplFXc+XIaSZchBB9BqlOKotfhH2BeSKFcAKBMAc4FAEBAQEBAQEBEQEKFglQgjCCFQEBAQMBEhEEGQEBLAsBBAsJAgsGBAEBAQ0dAgIiEgEFAQoKCAYTEhCHcwMPCAMLlAyPQoExPjGKVGeEQQEBBYg/A4QpAQEBAQEBAQEBAQEBAQEBAQEBAQEBFAgQhheETYRtglSCWQGGRgyRd4YDiCGBaU6HLYU4jhMSHoEPDw+CMIIQUooSAQEB X-IronPort-AV: E=Sophos;i="5.26,412,1459807200"; d="scan'208,217";a="221019246" Received: from mxout3.mail.janestreet.com ([38.105.200.229]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jun 2016 17:50:17 +0200 Received: from tot-qpr-mailcore2.delacy.com ([172.27.56.106] helo=tot-qpr-mailcore2) by mxout3.mail.janestreet.com with esmtps (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82) (envelope-from ) id 1b8rMW-0000JM-JN for caml-list@inria.fr; Fri, 03 Jun 2016 11:50:16 -0400 X-JS-Flow: external Received: by tot-qpr-mailcore2 with JS-mailcore (0.1) (envelope-from ) id BXUac4-AAAE2F-Ri; 2016-06-03 11:50:16.562402-04:00 Received: from mail-qg0-f70.google.com ([209.85.192.70]) by mxgoog1.mail.janestreet.com with esmtps (UNKNOWN:AES128-GCM-SHA256:128) (Exim 4.72) (envelope-from ) id 1b8rMW-0003Ct-Fo for caml-list@inria.fr; Fri, 03 Jun 2016 11:50:16 -0400 Received: by mail-qg0-f70.google.com with SMTP id p34so51654729qgp.3 for ; Fri, 03 Jun 2016 08:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=FZsvebllC8rDm+pZSlropTslcoBnQoay7NtftmpvXUc=; b=ExH1Ts/z1bXdN5nU6NKzu5aXdg04Vgy+0cwYNdAjMDuoDIUiLh44oFRjg6oCqwohfT kH15b0BfO3rYs4QcMfsI8ymuLgd3fMTVgCacRL8EfJmDSY7AS+cmQX13uRNLd6z2sVKI O+WjbA30jq8zuLGukts5gEA5p9NhZBRgEibrY= 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; bh=FZsvebllC8rDm+pZSlropTslcoBnQoay7NtftmpvXUc=; b=AANoFJQMxO5ZhxwZ3cYMujip1O+ZOesmMHjnbDbWb+XVfZuHLzGFze/79WY0O8bo9m ods60UVc1/htxKzLkrpuMJbYK0Z1MBgMLswV/KoUYJT5fd7BxbcsdCQN4rHp3JUNoYgt q4K0RU/c+97mYgxChf3xxtnInk+rtclSSeukfIdfbw+nupTVWt+tMbZqz9ksg9NAkyxg DxfY/ddDRI5kFHfS+EwdwRHIO6E9P90p+SnXSEhirBAQoa4fTDbjtH4TBiQXPftmstxz 3xSFv5YMVSlGW1zS8r4XqRpKfjTX9xJi33t3nIwas72KoIAFnkL4/ibSPLcyr5AJAVRu +O4A== X-Gm-Message-State: ALyK8tI3we/enGCwa5N2RhhwxbO6BMlsWCUBkFvAieZuBkgwdOfZuI/rGgdcM7uTY3D6yNGrF7K20wuGEez1RrjB4WZozaoQH5YRya6Q60nI+jXY35sekIfOn8Hfr/IEVnjY4mXiobutQIdW40dOqHlqon8y1Q0sRjwc1zx4sJU= X-Received: by 10.129.128.199 with SMTP id q190mr3028298ywf.319.1464969016212; Fri, 03 Jun 2016 08:50:16 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.129.128.199 with SMTP id q190mr3028287ywf.319.1464969016020; Fri, 03 Jun 2016 08:50:16 -0700 (PDT) Received: by 10.37.217.75 with HTTP; Fri, 3 Jun 2016 08:50:15 -0700 (PDT) In-Reply-To: References: Date: Fri, 3 Jun 2016 11:50:15 -0400 Message-ID: From:Yaron Minsky To:"Carette, Jacques" Cc:Jacques Garrigue , OCaML List Mailing Content-Type: multipart/alternative; boundary=94eb2c033810cec70b053461ade6 X-JS-Processed-by: mailcore Subject: Re: [Caml-list] Option to fully expand types in error messages? --94eb2c033810cec70b053461ade6 Content-Type: text/plain; charset=UTF-8 Diffs are often useful in visualizing such things. not sure how helpful it is in this case, but it does at least make it a bit clearer what's lined up. This was generated with our patdiff tool. @@@@@@@@@@ -1,7 +1,7 @@@@@@@@@@ val traverseexercise :-| *'a* container PseudoCode.abstract ->-| (*'a* PseudoCode.abstract ->-| *'b* PseudoCode.abstract -> (*'c* * *'b*) PseudoCode.abstract) ->-| *'b* PseudoCode.abstract* ->*-|* 'd container* ->-| (*'d* *container* *-*> *'c container* PseudoCode.*abstract -> 'e) -> 'e*+| loopdata container PseudoCode.abstract ->+| (loopdata PseudoCode.abstract ->+| loopdata PseudoCode.abstract ->+| (loopdata * loopdata) PseudoCode.abstract) ->+| loopdata PseudoCode.abstract ->+| (< answer : 'a; state : 'b; .. >, loopdata) PseudoCode.cmonad On Fri, Jun 3, 2016 at 11:42 AM, Carette, Jacques wrote: > So here is an actual example. The error I get is > ocamlc -short-paths -c reproduce.ml > File "reproduce.ml", line 148, characters 21-25: > Error: Signature mismatch: > ... > Values do not match: > val traverseexercise : > 'a container PseudoCode.abstract -> > ('a PseudoCode.abstract -> > 'b PseudoCode.abstract -> ('c * 'b) PseudoCode.abstract) -> > 'b PseudoCode.abstract -> > 'd container -> > ('d container -> 'c container PseudoCode.abstract -> 'e) -> 'e > is not included in > val traverseexercise : > loopdata container PseudoCode.abstract -> > (loopdata PseudoCode.abstract -> > loopdata PseudoCode.abstract -> > (loopdata * loopdata) PseudoCode.abstract) -> > loopdata PseudoCode.abstract -> > (< answer : 'a; state : 'b; .. >, loopdata) PseudoCode.cmonad > File "reproduce.ml", line 111, characters 6-206: Expected > declaration > File "reproduce.ml", line 125, characters 8-24: Actual declaration > > I can't tell from the above error what the actual cause is. The full code > is attached. [This code is quite reduced already. It is kept at this size > to show in more detail the kinds of errors we're seeing.] > > Any 'hint' from OCaml as to the precise nature of the non-match would sure > be appreciated. > > Jacques > > ________________________________________ > From: Jacques Garrigue [garrigue@math.nagoya-u.ac.jp] > Sent: June 2, 2016 19:59 > To: Carette, Jacques > Cc: OCaML List Mailing > Subject: Re: [Caml-list] Option to fully expand types in error messages? > > On 2016/06/03 04:18, "Carette, Jacques" wrote: > > > > In writing some code which uses a lot of monads with underlying types > which use constraints, even simple errors can lead to extremely hard to > read error messages. The main reason is that the two types given in errors > are partially expanded, to different levels. This frequently means that > the part where the type checker detects a mismatch is (extremely) opaque to > human eyes. > > > > In that case, it would actually be preferable to fully expand the > types. Yes, that will produce wallpaper. But at least the mismatch should > be considerably easier to catch. > > > > Does this already exist, or should I submit a feature request? > > > > Jacques > > In the error message, types are expanded just enough to get down to the > conflict. > If the conflict is not visible at that point, this is probably a scoping > error (and there should be an extra line stating that); > otherwise this should be seen as a bug. > As Yaron pointed, -short-paths can help by at least giving a normal form > for paths (which may not be the expansion, but should be unique in the > error context). But it will not expand a type if the expansion is not a > type constructor, or if the parameters are different. > > Jacques > > -- > 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 > --94eb2c033810cec70b053461ade6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Diffs are often useful in visualizing such things. =C2=A0n= ot sure how helpful it is in this case, but it does at least make it a bit = clearer what's lined up.=C2=A0 This was generated with our patdiff tool= .

@@@@@@@@@@ -1,7 +1,7 @@@@@@@@@@
           val traverseexercise :
-|           'a container PseudoCode.abstract ->
-|           ('a PseudoCode.abstract ->
-|            'b PseudoCode.abstract -> ('c * 'b) PseudoCode.abstract) ->
-|           'b PseudoCode.abstract ->
-|           'd container ->
-|           ('d container -<=
/span>> 'c container PseudoCode.abstract -> 'e) -&g=
t; 'e
+|           loopdata cont=
ainer PseudoCode.abstract ->
+|           (loopdata Pse=
udoCode.abstract ->
+|            loopdata Pse=
udoCode.abstract ->
+|            (loopdata * =
loopdata) PseudoCode.abstract) -&=
gt;
+|           loopdata Pseu=
doCode.abstract ->
+|           (< answer : 'a; state : 'b; .. >, loopdata) PseudoCode.<=
span style=3D"color:rgb(0,136,0)">cmonad

On Fri, Jun 3, 2016 at 11:4= 2 AM, Carette, Jacques <carette@mcmaster.ca> wrote:
So here is an actual example.=C2=A0 The error I= get is
ocamlc -short-paths -c reproduce.ml
File "reproduce.ml", line 148, characters 21-25:
Error: Signature mismatch:
=C2=A0 =C2=A0 =C2=A0 =C2=A0...
=C2=A0 =C2=A0 =C2=A0 =C2=A0Values do not match:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0val traverseexercise :
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'a container PseudoCode.abstra= ct ->
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0('a PseudoCode.abstract -><= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 'b PseudoCode.abstract -> = ('c * 'b) PseudoCode.abstract) ->
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'b PseudoCode.abstract -> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'd container ->
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0('d container -> 'c con= tainer PseudoCode.abstract -> 'e) -> 'e
=C2=A0 =C2=A0 =C2=A0 =C2=A0is not included in
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0val traverseexercise :
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0loopdata container PseudoCode.abst= ract ->
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(loopdata PseudoCode.abstract ->= ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 loopdata PseudoCode.abstract ->= ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (loopdata * loopdata) PseudoCode.= abstract) ->
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0loopdata PseudoCode.abstract ->=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(< answer : 'a; state : = 9;b; .. >, loopdata) PseudoCode.cmonad
=C2=A0 =C2=A0 =C2=A0 =C2=A0File "reproduce.ml", line 111, charact= ers 6-206: Expected declaration
=C2=A0 =C2=A0 =C2=A0 =C2=A0File "reproduce.ml", line 125, charact= ers 8-24: Actual declaration

I can't tell from the above error what the actual cause is.=C2=A0 The f= ull code is attached.=C2=A0 [This code is quite reduced already.=C2=A0 It i= s kept at this size to show in more detail the kinds of errors we're se= eing.]

Any 'hint' from OCaml as to the precise nature of the non-match wou= ld sure be appreciated.

Jacques

________________________________________
From: Jacques Garrigue [gar= rigue@math.nagoya-u.ac.jp]
Sent: June 2, 2016 19:59
To: Carette, Jacques
Cc: OCaML List Mailing
Subject: Re: [Caml-list] Option to fully expand types in error messages?

On 2016/06/03 04:18, "Carette, Jacques" wrote:
>
> In writing some code which uses a lot of monads with underlying types = which use constraints, even simple errors can lead to extremely hard to rea= d error messages.=C2=A0 The main reason is that the two types given in erro= rs are partially expanded, to different levels.=C2=A0 This frequently means= that the part where the type checker detects a mismatch is (extremely) opa= que to human eyes.
>
> In that case, it would actually be preferable to fully expand the type= s.=C2=A0 Yes, that will produce wallpaper.=C2=A0 But at least the mismatch = should be considerably easier to catch.
>
> Does this already exist, or should I submit a feature request?
>
> Jacques

In the error message, types are expanded just enough to get down to the con= flict.
If the conflict is not visible at that point, this is probably a scoping er= ror (and there should be an extra line stating that);
otherwise this should be seen as a bug.
As Yaron pointed, -short-paths can help by at least giving a normal form fo= r paths (which may not be the expansion, but should be unique in the error = context). But it will not expand a type if the expansion is not a type cons= tructor, or if the parameters are different.

Jacques

--
Caml-list mailing list.=C2=A0 Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocam= l_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

--94eb2c033810cec70b053461ade6--