Note that there are some explanatory texts on larger screens.

plurals
  1. POIs non-local type inference in Haskell or OCaml really useful?
    primarykey
    data
    text
    <p>First, let us assume that local type inference is the sort of type inference found in Scala and C#. Scala local type inference is explained here: <a href="http://www.scala-lang.org/node/127" rel="nofollow">http://www.scala-lang.org/node/127</a> </p> <p>Also, let us assume, that a definition such as</p> <pre><code> fact 0 = 1 fact n = n * fact(n-1) </code></pre> <p>would count as local type inference -- that is, type inference here is local to function fact. Scala does not permit such a type inferece; still let us count it as local.</p> <p>The question, then, is whether anyone has a practical example of at least 2 mutually-recursive functions (or any other non-locality at your discretion) that derive some benefit from type inference? Please do not post silly examples such as:</p> <pre><code> odd 0 = false odd n = even(n-1) even 0 = true even n = odd(n-1) </code></pre> <p>I suspect that non-silly, practical examples arise in parses. Also, please could you explain the benefits a programmer could derive from such uses of non-local type inference?</p> <p>UPDATE:</p> <p>I appreciate any example of insufficiency of local type inference and the need for full-blown type inference.</p> <ol> <li><p>Your Haskell or OCaml example may be 90% correct, because you are only 90% understand the term "non-local type inference". Still, you have to understand Haskell (or OCaml) type inference. </p></li> <li><p>Your example may be written on Scala or C#. Please point out that compliler really has enough information to infer the type, but the type can not be inferred due to language specification or due to local-only nature of type inference in Scala or C#.</p></li> </ol> <p>// And again, feel free to correct my english.</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.
 

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