[Haskell-cafe] Maybe a compiler bug?

Neil Mitchell ndmitchell at gmail.com
Tue Jan 6 05:20:17 EST 2009


Hi

> gTst3 right left = if (lr > ll)  then  False else True
> 			where lr = length (right ! 2)
> 			      ll = length (left ! 2)

Running this code over HLint (http://www.cs.york.ac.uk/~ndm/hlint) says:

Example.hs:8:1: Error: Redundant if
Found:
  if (lr > ll) then False else True
Why not:
  not (lr > ll)

Making that change and running it again gives:

Example.hs:8:1: Error: Use <=
Found:
  not (lr > ll)
Why not:
  lr <= ll

Which ends up with something similar to what you came up with.
However, if we take your final answer:

> gTst3 right left = (lr <= ll)
> 			where lr = length (right ! 2)
> 			      ll = length (left ! 2)

We get:

Example.hs:8:1: Warning: Redundant brackets
Found:
  (lr <= ll)
Why not:
  lr <= ll

Leaving us with the HLint 1.0 compliant (TM) :

gTst3 right left = lr <= ll
			where lr = length (right ! 2)
			      ll = length (left ! 2)

Thanks

Neil


More information about the Haskell-Cafe mailing list