caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Josh Berdine <josh@berdine.net>
To: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] ignore in postfix position
Date: Wed, 7 Feb 2018 11:09:49 +0000	[thread overview]
Message-ID: <75974590-FF69-4007-BC38-77D567E918CF@berdine.net> (raw)
In-Reply-To: <5d17ed87-e78d-f9c4-ae42-382f4c2ed353@gerd-stolpmann.de>

Hi Gerd,

> On Jan 9, 2018, at 11:49 AM, Gerd Stolpmann <info@gerd-stolpmann.de> wrote:
> 
> the "ignore" function behaves specially when applied to a partial function:
> 
> # ignore (fun _ -> ());;
> Warning 5: this function application is partial,
> maybe some arguments are missing.
> 
> This very useful warning is not emitted, however, when I switch to a
> slight variation, like:
> 
> # (fun _ -> ()) |> ignore
> 
> I like this post-fix syntax more than the original because "ignore"
> isn't then as distracting, but it's a pity that the warning can no
> longer be generated. I am wondering whether this behavior is deeply
> anchored in the inference engine or whether this is improvable.

I don't know if treating reverse application similarly to the current treatment of application would be difficult, but as an alternative I tend to put a type ascription on ignore:

# (fun _ -> ()) |> (ignore : unit -> _);;
Error: This expression has type unit -> unit
but an expression was expected of type ('a -> unit) -> 'b
Type unit is not compatible with type 'a -> unit

Cheers, Josh

      reply	other threads:[~2018-02-07 11:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-09 11:49 Gerd Stolpmann
2018-02-07 11:09 ` Josh Berdine [this message]

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=75974590-FF69-4007-BC38-77D567E918CF@berdine.net \
    --to=josh@berdine.net \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).