The Do-Let-Braces problem
Marcin 'Qrczak' Kowalczyk
qrczak@knm.org.pl
15 Feb 2001 07:59:08 GMT
Thu, 15 Feb 2001 15:20:19 +1300, Mark Utting <marku@goblin.cs.waikato.ac.nz> pisze:
> fb::IO ()
> fb =
> do {
> putStr "Enter Data: ";
> line <- getLine;
> let line2 = line;
> putStr line2;
> }
I have a different proposal. Let's drop the 'let' keyword in value
bindings in a 'do' block!
The largest continouos block of bindings is translated to a single 'let'.
(They can define a function by cases and can be mutually recursive.)
fb1 ::IO ()
fb1 =
do {
putStr "Enter Data: ";
line <- getLine;
line2 = line;
putStr line2;
}
fb2 ::IO ()
fb2 = do
putStr "Enter Data: "
line <- getLine
line2 = line
putStr line2
A disadvantage of let is that when the definition must be continued
on the next line, the word after 'let' set the indentation and the
continuation must be indented more than expected:
do
foo
let x = a very long expression - note that the next line
must be indented *too much*!
bar
I would like to have indents of the width four and a single indent here.
My proposal solves both of these problems.
A disadvantage: it breaks code which uses separate 'let' clauses
which shadow their variables.
--
__("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZASTĘPCZA
QRCZAK