Breaking up long lines

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Breaking up long lines

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?

Lycos email has 300 Megabytes of free storage... Get it now at mail.lycos.co.uk
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Breaking up long lines

Neil Mitchell
Hi,

> What is a good technique for breaking up long lines of code (for easier readability)?
Indentation, the {- -} comments are probably having little effect.

For example, the following is perfectly valid:

f x y = if x then
                y
          else
                not y

The indentation rules are quite complex, but just type your code
"sensibly indented" and it will probably just work.

Thanks

Neil

On 4/2/06, miketerrance <[hidden email]> wrote:

>
> I have been inserting {- -} comments but there must be a better way.  Something like \ in Python?
>
> Lycos email has 300 Megabytes of free storage... Get it now at mail.lycos.co.uk
>
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Breaking up long lines

Donald Bruce Stewart
In reply to this post by miketerrance
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
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Breaking up long lines

Bugzilla from 1@234.cx
In reply to this post by Neil Mitchell
Neil Mitchell wrote:

> The indentation rules are quite complex, but just type your code
> "sensibly indented" and it will probably just work.

My biggest problem in this area was following haskell-mode's defaults
too strictly.  I found that things ended up indented more than was
necessary for clear layout, so wasting a lot of the space I had
available.

Pete



_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe