hlint and DoIfThenElse

hlint gives me a parse error on a clause using DoIfThenElse, even if I have the language pragma. I don't see any hlint options to get around that, are there any? 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 thanks Lee

On Tue, 22 Nov 2011 14:46:37 -0800
Lee Short
hlint gives me a parse error on a clause using DoIfThenElse, even if I have the language pragma. I don't see any hlint options to get around that, are there any?
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
You've just pressed one of my language-independent style hot
buttons. Why on earth are you using an if/then/else here? What's wrong
with the straightforward:
return "" == results
The expression results in a boolean, and it's even the one you want to
return. So why not return it?

On Tue, Nov 22, 2011 at 8:58 PM, Mike Meyer
You've just pressed one of my language-independent style hot buttons. Why on earth are you using an if/then/else here? What's wrong with the straightforward:
return "" == results
The expression results in a boolean, and it's even the one you want to return. So why not return it?
Minor nitpick since we are on 'begginers' list: you need parenthesis there, so either return ("" == results) or return $ "" == results otherwise it would get parsed as '(return "") == results'. Also, note that instead of doing "" ==, you could use 'null', so return (null results) HTH, -- Felipe.

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).
participants (4)
-
Daniel Fischer
-
Felipe Almeida Lessa
-
Lee Short
-
Mike Meyer