Hacker News new | past | comments | ask | show | jobs | submit login

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.)




var 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.


"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. =)


I don't think you can assign a lambda expression to a var in C#.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: