3 ms·
Hindley-Milner is easy, as long as you throw either subtyping or recursion out the window. ;) (IIRC) (Doesn't C# basically use HM to support the var keyword, a
by crux_ 18y ago
Hindley-Milner is easy, as long as you throw either subtyping or recursion out the window. ;) (IIRC)
(Doesn't C# basically use HM to support the var keyword, anyway? That's what I'd do.)
- olavk 18y agovar in C# is only allowed for local variables, which means you can easily infer the type by analysing the assigment expression, which will always depend on known types. For example method parameters are always explicitly typed. Haskell style type inference is more tricky, since it also tries to infer the type of function signatures from the different contexts where the function is called. This can lead to circular type dependencies.
- crux_ 18y ago"Easily"? I suspect that since C#3 offers lambda expressions that you'd need to use something close to (although probably different from) full H-M inference... in fact, it seems like it may need to be nearly as complicated as Scala's type inference, which is saying something. =)
- olavk 18y agoI don't think you can assign a lambda expression to a var in C#.