<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Thanks a lot for these paper reference and detailed explanation. I have a lot to read now ;)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><div>Here's a reasonable plan:<br></div><div><br></div><div>1) Start with so-called "Unification" [1]. Try manually inferring the types of some Haskell fragments to get a sense of how it applies. The connection should emerge as clear as day.<br>





<br></div><div>2) Next, study Damas-Hindley-Milner. Gain a sense of what motivates 'principal types', why they're useful, as opposed to a situation where they are impossible to infer.<br><br></div><div>3) Finally, there's type classes. I don't know if typed clojure has them or not, but this is really what separates Haskell from, say, Lazy ML (LML). Be warned, this is where it gets gnarly.<br>





</div><div><br>[1] <a href="http://en.wikipedia.org/wiki/Unification_%28computer_science%29" target="_blank">http://en.wikipedia.org/wiki/Unification_%28computer_science%29</a></div></div></blockquote><div><br></div><div>



Wow, thanks for this such a detailed plan, I'm also new to type system, it seems that all the later type inference algorithm is base on Damas-Hindley-Milner, I must start from here.</div><div><br></div><div>The feature that typed clojure misses is some ability to do fully automatic type inference, here are some example:</div>


<div><br></div><div>map is a polymorphic function with type `(a -> b) -> [a] -> [b]`, and so does identity function of type `a -> a`, here are invocation: `map identity [1,2,3]`, haskell could successfully inference its type, but typed clojure is unable to do this fully automatically, we had to <span style="font-family:arial,sans-serif;font-size:14px">instantiate either map or identity manually.</span></div>
<div><span style="font-family:arial,sans-serif;font-size:14px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:14px">The author of typed clojure given me this <a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.39.7265">paper</a>, and to quote from paper:</span></div>
</div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div>When a polymorphic function is given an anonymous function as argument, we have a situation where either one of these techniques can be used to infer some type annotations, but not both at the same time. For example, in the term map (fun x -> x) [1,2,3], we cannot infer both the type arguments to map and the annotation on the function parameter x for the following reason. We take the simple approach that all the the arguments' types must be determined before calculation of any missing type arguments. This means that the type of the anonymous function must be synthesized with the concrete type of its parameter not available from the context. This synthesis immediately fails, since the parameter is not annotated with its type.</div>
</div></div></blockquote><br><div>So, I'd like to know how haskell solved this problem?</div><div><br></div><div>Thanks</div></div>