[Haskell-cafe] Unifcation and matching in Abelian groups
Neil Mitchell
ndmitchell at gmail.com
Wed Aug 19 06:16:06 EDT 2009
Hi,
I ran your code thought HLint
(http://community.haskell.org/~ndm/hlint), and it suggested a couple
of things (mainly eta reduce). The most interesting suggestions are on
your main function:
> main :: IO ()
> main =
> do
> done <- isEOF
> case done of
> True -> return ()
> False ->
> do
> prob <- getLine
> test prob
> main
It suggests:
Example.lhs:432:3: Warning: Use if
Found:
case done of
True -> return ()
False -> do prob <- getLine
test prob
main
Why not:
if done then return () else
do prob <- getLine
test prob
main
Changing that and rerunning says:
Example.lhs:432:3: Error: Use unless
Found:
if done then return () else
do prob <- getLine
test prob
main
Why not:
unless done $
do prob <- getLine
test prob
main
So I (or rather HLint) recommends you do:
> main :: IO ()
> main =
> do
> done <- isEOF
> unless done $ do
> prob <- getLine
> test prob
> main
Thanks, Neil
More information about the Haskell-Cafe
mailing list