At Tue, 1 Jun 2004 19:04:56 -0400,
Nathan Weston wrote:
> 
> I am learning haskell from "The Haskell School of Expression", and finding the 
> indentation in the emacs mode rather unhelpful. When I try to type in the 
> following example from the book:
> 
> main = runGraphics (
>        do w <- openWindow "Graphics" (300,300)
>           drawInWindow w (text(100,200) "Hello, world!")
>           k <- getKey w
>           closeWindow w       
>                  )
> 
> emacs wants to indent it like so:
> 
> main = runGraphics (
>        do w <- openWindow "Graphics" (300,300)
>        drawInWindow w (text(100,200) "Hello, world!")
>        k <- getKey w
>        closeWindow w       
>                  )
> 
> (For those not using a fixed-width font, in the first example, everything 
> lines up under the 'w <-', in the second, everything lines up under the 'do')
> 
> If I let emacs have its way, I get a syntax error.
> Am I doing something wrong here? Is the emacs mode broken?

The emacs mode definately leaves much to be desired, you could try
formatting the code like this instead:

main = runGraphics $
       do w <- openWindow "Graphics" (300,300)
          drawInWindow w (text(100,200) "Hello, world!")
          k <- getKey w
          closeWindow w

The type signature for $ is:

($) :: forall b a. (a -> b) -> a -> b

I think the ($) operator was invented entirely for rewriting
expressions without parens...

Jeremy Shaw.
--

This message contains information which may be confidential and privileged. Unless you 
are the 
addressee (or authorized to receive for the addressee), you may not use, copy or 
disclose to anyone 
the message or any information contained in the message. If you have received the 
message in error, 
please advise the sender and delete the message.  Thank you.
_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to