Right, but they can't be inferred on objects and records either, and yet they're allowed there... so what was the rationale?

On Mon, May 16, 2016 at 2:53 PM, Gregory Malecha <gmalecha@gmail.com> wrote:

There may other reasons as well, e.g. performance and compilability, but the main reason that I know is that inferring these types is difficult (undecideable in general). For a point of comparison, GHC supports types like this, but only when they are explicitly written.


On Mon, May 16, 2016, 11:50 AM Yotam Barnoy <yotambarnoy@gmail.com> wrote:
Paging the type experts -- is there a concrete reason why we disallow writing this type directly?

On Mon, May 16, 2016 at 1:32 PM, Gerd Stolpmann <info@gerd-stolpmann.de> wrote:
Am Montag, den 16.05.2016, 17:55 +0100 schrieb Guillaume Hennequin:
> Thanks all for your prompt answers;
>
> > See the FAQ entry, "How to write a function with polymorphic arguments?"
> >   https://ocaml.org/learn/faq.html#Howtowriteafunctionwithpolymorphicarguments
>
> this page explains how to do it with records or objects, but ends with a
> mysterious "FIXME: a direct way now exists". Does anyone know what this might
> refer to?

What you would need is

let print_both : ('a . 'a -> 'a) -> unit = ...

i.e. the scope of the quantifier is restricted to the first argument.
This doesn't exist to my knowledge. Maybe it was part of some dev
version?

Gerd
--
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
My OCaml site:          http://www.camlcity.org
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
------------------------------------------------------------


--

- gregory malecha
  gmalecha.github.io