User loginNavigation |
Extending HM type inference -- would this be possible? Or even desirable?I wonder whether the following extension to the type inference mechanisms of languages like Haskell, ML, etc. would be possible, and, if so, desirable. Today we write functions like head (a:_) = a and get warning messages concerning patterns not covering all possibilities. This is fine. However, I am not being warned when the compiler sees code like head [] (even when head were defined like above, without a default clause that raises a runtime error.) In principle, though, the type inference could collect for each value of algebraic datatype by which constructor this value could possibly have been created. For example, the type of The consequence would be that it would be no longer worth a warning when writing functions with incomplete patterns. Rather, at the place where the function is used the compiler would be able to diagnose one of three outcomes: Case 1 could be treated like just another type error. Case 2 could provoke a warning. Case 3 is ok, of course. To be sure, that would also encourage a different style. Instead of writing dozens of meanigless default cases like (I hope I could express my thoughts clear enough despite english not being my native language.) By Ingo Wechsung at 2007-09-13 14:47 | LtU Forum | previous forum topic | next forum topic | other blogs | 6474 reads
|
Browse archives
Active forum topics |
Recent comments
22 weeks 6 days ago
22 weeks 6 days ago
22 weeks 6 days ago
45 weeks 19 hours ago
49 weeks 2 days ago
50 weeks 6 days ago
50 weeks 6 days ago
1 year 1 week ago
1 year 6 weeks ago
1 year 6 weeks ago