Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>_</code> denotes a weakly polymorphic variable : it is in a position where it cannot be generalized.</p> <p>There are two explanations related to weak polymorphism in the OCaml FAQ: see <a href="http://caml.inria.fr/resources/doc/faq/core.en.html#eta-expansion" rel="noreferrer">A function obtained through partial application is not polymorphic enough</a> and the next one.</p> <p>This generally happens when you're using a non-local reference (whose type cannot be generalized), or when defining polymorphic functions that are not syntactically functions (they do not begin with <code>fun x -&gt; ..</code> but rather a function application). In some cases there is an easy fix (eta-expansion, see the FAQ), sometimes there isn't, and sometimes your program was just unsound.</p> <p>An easy example : <code>let a = ref []</code> does not get the polymorphic <code>a list ref</code> type. Otherwise you could use both as a <code>int list</code> and a <code>bool list</code>, and mix elements of different types by mutating the reference. It instead get a <code>'_a list ref</code> type. This mean that the type is not polymorphic, but merely <em>unknown</em>. Once you do something with <code>a</code> with a particular type, it fixes <code>'_a</code> once and for all.</p> <pre><code># let a = ref [];; val a : '_a list ref = {contents = []} # let sum_of_a = List.fold_left (+) 0 !a;; val sum_of_a : int = 0 # a;; - : int list ref = {contents = []} </code></pre> <p>For an in-depth explanation of value restriction and the "relaxed" value restriction actually implemented in the OCaml type checker, see the <a href="http://caml.inria.fr/pub/papers/garrigue-value_restriction-fiwflp04.pdf" rel="noreferrer">Relaxing the Value Restriction</a> paper by Jacques Garrigue (2004).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload