[Haskell-cafe] Breaking up long lines
Donald Bruce Stewart
dons at cse.unsw.edu.au
Sat Apr 1 21:36:11 EST 2006
miketerrance:
> What is a good technique for breaking up long lines of code (for easier readability)?
>
> I have been inserting {- -} comments but there must be a better way. Something like \ in Python?
Can you give an example?
Usually breaking long lines is just a matter of cutting on white space:
lookupP (a,b) cmd = withModule ircCommands cmd
(error $ "Parse error: " ++ show cmd)
(\m -> do
privs <- gets ircPrivCommands -- no priv commands can be composed
when (cmd `elem` privs) $ error "Privledged commands cannot be composed"
return $ \str -> catchError
(process m a b cmd str)
(\ex -> case (ex :: IRCError) of
(IRCRaised (NoMethodError _)) -> process_ m cmd str
_ -> throwError ex))
once things get too big, use 'where' clauses .
Actually, use 'where' clauses when things aren't too big, anyway :)
There's also a set of programming guidelines here:
http://haskell.org/haskellwiki/Programming_guidelines
-- Don
More information about the Haskell-Cafe
mailing list