3 ms·
Haskell's type system is great, unless you need semi unification (equivalent to nominal subtyping and imperative assignment), then it's not so great anymore. Un
by seanmcdirmid 12y ago
Haskell's type system is great, unless you need semi unification (equivalent to nominal subtyping and imperative assignment), then it's not so great anymore. Unification is pretty limiting.
- tome 12y agoCould you explain a bit more? A quick search suggests that semi-unification is equivalent to Milner-Mycroft typeability, which is polymorphic recursion, which Haskell does indeed have. http://homepages.dcc.ufmg.br/~camarao/SUP/ http://homepages.dcc.ufmg.br/~camarao/SUP/ http://en.wikipedia.org/wiki/Polymorphic_recursion http://en.wikipedia.org/wiki/Polymorphic_recursion
- seanmcdirmid 12y agoRight, but not without type inference. One of the reasons Scala's type system is quite complicated is that it can do semi-unification to achieve local type inference, at least (semi-unification is undecidable in general, and Scala makes a best effort, I believe). How does Haskell deal with refs?
- tome 12y agoI'm not sure what you mean. I'm not aware of any type inference difficulties with IORefs or STRefs. Polymorphic recursion, on the other hand, does often (or maybe always) require an explicit type signature.
- seanmcdirmid 12y agoIf you were to do type inference across mutable reference assignments, you would have to do some semi unification. I don't think haskell does, even ML treats refs very strangely.
- codygman 12y agoThat sounds like something you'd use the state monad for if I understand correctly. Can you provide an example of semi unification where Haskell would be not so great?