Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Ivan Gotovchits <ivg@ieee.org>
To: SP <sp@orbitalfox.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Improved type error messages for Ocaml
Date: Thu, 12 Jan 2017 17:10:36 -0500	[thread overview]
Message-ID: <CALdWJ+xXc47jGS60vtbAudbjLQ0yVM=O7B5RoW=-OwvpyGX-Dw@mail.gmail.com> (raw)
In-Reply-To: <89b3a273-ed12-b1ed-202b-f1e3610c00e0@orbitalfox.com>

[-- Attachment #1: Type: text/plain, Size: 1412 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 3078 bytes --]

  reply	other threads:[~2017-01-12 22:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-10 10:45 Arthur Charguéraud
2017-01-12 21:37 ` SP
2017-01-12 22:10   ` Ivan Gotovchits [this message]
2017-01-13 15:43     ` Arthur Charguéraud

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALdWJ+xXc47jGS60vtbAudbjLQ0yVM=O7B5RoW=-OwvpyGX-Dw@mail.gmail.com' \
    --to=ivg@ieee.org \
    --cc=caml-list@inria.fr \
    --cc=sp@orbitalfox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox