On Thu, Oct 3, 2013 at 1:52 PM, Alan Buxton <alanbuxton@gmail.com> wrote:--niceShow x = if isInt x then show (floor x :: Int) else show x
I get a warning about a “too strict if”. If I then follow the recommendation and change niceShow to be
show (if isInt x then (floor x :: Int) else x)
Then I get an error that Couldn't match expected type `Int' with actual type `Double' which makes sense because floor x :: Int produces an Int but x alone is a Double. Surely hlint could have figured this out from the type signatures and not made the recommendation to change my if structure?
hlint doesn't recognize types, only code structure to some extent (it is a parser, not a compiler). As such, it will sometimes produce bad advice like that."Too strict if" pretty much means what you saw... that you have the same structure in both legs and it thinks you should abstract it out. But, as I noted, it doesn't know about types so it can't recognize that you can't type the refactored expression. In fact I'd generally claim that "Too strict if" is by far its worst designed diagnostic, because of its inability to recognize types and because the resulting message is incomprehensible.In short, take hlint's diagnostics with several grains of salt.brandon s allbery kf8nh sine nomine associatesunix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners