[Haskell-cafe] Request for comments - hdnsomatic
Neil Mitchell
ndmitchell at gmail.com
Sun Aug 16 17:43:12 EDT 2009
Hi
An easy way to get some instant feedback is to run HLint on it:
http://community.haskell.org/~ndm/hlint
The results are:
C:\Neil\hlint>hlint Example.hs
Example.hs:42:1: Warning: Use liftM
Found:
readFile p >>= return . lines >>=
return . map (second tail . break (== '=') . filter (/= ' '))
Why not:
liftM (map (second tail . break (== '=') . filter (/= ' ')))
(readFile p >>= return . lines)
Example.hs:42:1: Warning: Use liftM
Found:
readFile p >>= return . lines
Why not:
liftM lines (readFile p)
Found 2 suggestions
So using liftM instead of >>= return might be better style.
You can also make minor tweaks like:
if null args then readConfig defaultConfig else readConfig (head args)
==>
readConfig $ if null args then defaultConfig else head args
currentIP <- catch (getIPAddress webIP) (\e -> syslog Error (show e)
>> return "0")
oldIP <- catch (S.readFile ipCache) (\e -> syslog Error (show e) >>
return "0")
==>
let catch_ x = catch x (\e -> syslog Error (show e) >> return "0")
currentIP <- catch_ $ getIPAddress webIP
oldIP <- catch_ (S.readFile ipCache)
And there's no need to exitSuccess at the end of main, exitSuccess is
the default.
Thanks
Neil
2009/8/16 Jesús Alberto Sánchez Pimienta <jesusalbertosanchez at gmail.com>:
> Hello haskellers,
>
> I just finished my first useful haskell program and I'd be glad if you make
> me some comments
>
> http://hpaste.org/fastcgi/hpaste.fcgi/view?id=8244#a8244
>
> Thank you, and sorry for my english.
>
>
> "Piensa y trabaja"
>
> Jesús Alberto Sánchez Pimienta
> Estudiante de la Lic. en Estudios Políticos y Gobierno
> Universidad de Guadalajara
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
More information about the Haskell-Cafe
mailing list