[Haskell-beginners] hlint and DoIfThenElse

Daniel Fischer daniel.is.fischer at googlemail.com
Wed Nov 23 00:06:04 CET 2011


On Tuesday 22 November 2011, 23:46:37, Lee Short wrote:
>  hlint gives me a parse error on a clause using DoIfThenElse, even if I
>  have the language pragma.

hlint probably has its own parser which doesn't yet implement that 
extension.

>  I don't see any hlint options to get around
>  that, are there any?

Just indent the then and else lines a bit more.

> 
>  Is it considered good style to write code like this?
> 
>  if "" == results
>  then return True
>  else return False
> 
>  The obvious way rewrite below just seems clunky to me (though I can see
>  how others might prefer it to the code above).
> 
>  return $ if "" == results
>           then True
>           else False


The obvious rewrite is

    return (null results)

`if condition then True else False' is the same as `condition', which is 
clearer (and shorter).





More information about the Beginners mailing list