From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 2DDB17FFD7 for ; Fri, 13 Jan 2017 16:43:58 +0100 (CET) X-IronPort-AV: E=Sophos;i="5.33,222,1477954800"; d="scan'208,217";a="255223662" Received: from ede67-3-82-235-53-116.fbx.proxad.net (HELO [192.168.0.10]) ([82.235.53.116]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 13 Jan 2017 16:43:56 +0100 To: caml-list@inria.fr References: <89b3a273-ed12-b1ed-202b-f1e3610c00e0@orbitalfox.com> From: =?UTF-8?Q?Arthur_Chargu=c3=a9raud?= Message-ID: <4d7b6519-0bec-461a-db74-7466aae8c4d6@inria.fr> Date: Fri, 13 Jan 2017 16:43:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------8376609509C21DEAB7B59C60" Subject: Re: [Caml-list] Improved type error messages for Ocaml This is a multi-part message in MIME format. --------------8376609509C21DEAB7B59C60 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi Ivan, Thanks for your feedback. # print_int 2+2;; I don't like the idea of testing whether the term would type-check with a different parenthesization. First of all, it might be expensive or complex to test. Second, it may lead to suggestions that are even more confusing. One proposal that I would like better to handle your scenario is the following: if an infix binary operator (other than ';') has a first argument of type unit, then suggest that parentheses might be missing. I can try to implement that, unless someone argues against this proposal. Thanks, + Arthur > Impressive! > > By the way, one of the most common mistakes is to forget that a > function application binds tighter than > infix operators, e.g., > > > # print_int 2+2;; > > Although your branch already provides a nice error message: > > Error: The function `+' cannot be applied to the arguments provided. > > | Types of the expected arguments: | Types of the provided > arguments: > ---|-------------------------------------|------------------------------------ > 1 | int | unit > 2 | int | int > > > that is probably better than the default: > > Error: This expression has type unit but an expression was > expected of type > int > > it is still probably a good idea, to provide an ad-hoc error message > here (as you did for missing `()`, `!` and `rec`). > > In this case, if an offending expression contains a binary operator > which has an application to the left and some simpl_expr > on the right, and if we can fix it by parenthesizing the expression, > then we can suggest adding parentheses around the expression. > > Regards, > Ivan Gotovchits > > On Thu, Jan 12, 2017 at 4:37 PM, SP > wrote: > > Nice! > > -- > SP > > -- > 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 > > > --------------8376609509C21DEAB7B59C60 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

Hi Ivan,

Thanks for your feedback.

# print_int 2+2;;

I don't like the idea of testing whether the term would type-check with a different parenthesization. First of all, it might be expensive or complex to test. Second, it may lead to suggestions that are even more confusing.

One proposal that I would like better to handle your scenario is the following: if an infix binary operator (other than ';') has a first argument of type unit, then suggest that parentheses might be missing.

I can try to implement that, unless someone argues against this proposal.

Thanks,
+
Arthur

Impressive!

By the way, one of the most common mistakes is to forget that a function application binds tighter than 
infix operators, e.g.,


       # print_int 2+2;;

Although your branch already provides a nice error message:

Error: The function `+' cannot be applied to the arguments provided.

   | Types of the expected arguments:    | Types of the provided arguments:
---|-------------------------------------|------------------------------------
 1 | int                                 | unit
 2 | int                                 | int

that is probably better than the default:

Error: This expression has type unit but an expression was expected of type
         int

it is still probably a good idea, to provide an ad-hoc error message here (as you did for missing `()`, `!` and `rec`). 

In this case, if an offending expression contains a binary operator which has an application to the left and some simpl_expr 
on the right, and if we can fix it by parenthesizing the expression, then we can suggest adding parentheses around the expression. 

Regards,
Ivan Gotovchits

On Thu, Jan 12, 2017 at 4:37 PM, SP <sp@orbitalfox.com> wrote:
Nice!

--
    SP

--
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



--------------8376609509C21DEAB7B59C60--