Re:Why do dynamic languages make it more difficult to mainta...
by tel on Monday January 27, 2014 @03:06PM
(#7132807)
It's also pretty easy and useful to step out of the HM, inferable fragment using any number of popular language extensions. I'm not arguing that it's a problem, but it's disingenuous to suggest that anything resembling all code can be type-inferred.
Re:Why do dynamic languages make it more difficult to mainta...
by asdasf on Tuesday January 28, 2014 @09:44AM
(#7137289)
I don't think so. We are talking about haskell after all, not haskell + experimental ghc extensions. And which popular extensions break type inference anyways?
Re:Why do dynamic languages make it more difficult to mainta...
by tel on Friday January 31, 2014 @10:25AM
(#7157087)
RankNTypes are pretty popular in libraries and break total inference. You don't need to enable the extension personally to suffer it either.
Re:Why do dynamic languages make it more difficult to mainta...
by ent on Monday January 27, 2014 @02:59PM
(#7132766)
But the cool thing is that in many (most?) cases you can actually infer the type of reading from a string. You are going to do something with that value right? So you can say
1 + (read "1")
and the compiler will know that you must want to read "1" as a number and does that!
Re:Why do dynamic languages make it more difficult to mainta...
by dllthomas on Thursday January 30, 2014 @10:36PM
(#7155086)
Yeah, I most commonly hit "oh, I need to annotate that" when I'm building some expression piece by piece in ghci, and so effectively what I'm doing with that value is "print it, as appropriate to the type" - which doesn't tell us much about what type it is.
Re:Why do dynamic languages make it more difficult to mainta...
by platz on Monday January 27, 2014 @03:25PM
(#7132961)
That kind inference only works because + is defined to work on Nums only (importing only prelude). You don't even need the initial 1. A nice trick but these are rather small details.
Re:Why do dynamic languages make it more difficult to mainta...
by TylerE on Monday January 27, 2014 @03:32PM
(#7133001)
With the caveat that the compiler can come up with A consistent inferred typing, but it may not be the exact type you had in mind, especially when dealing with numerics. This is very rarely a problem, but in some cases may result in less optimized code than might be possible with a stricter annotation.
note: Yes I know the compiler can't actually infer all types all the time, but the exceptions are obvious and require type information in dynamically typed languages too (ie. convert a string to an int: you have to tell it you want an int, you can't just say "convert this string" and have it guess what you want it converted to).