Compiler error using IO
Ashley Yakeley
ashley@semantic.org
Fri, 4 Jan 2002 08:25:00 -0800
>| while :: IO Bool -> IO () -> IO ()
>|
>| while test action = do res <- test
>| if res then do action
>| while test action
>| else return ()
>
>Haskell uses "layout" to reduce the need for parentheses. For your code to
>parse, "if" should align with "res" vertically, as in:
>
> ... = do res <- test
> if res ...
The "layout" rules drive me nuts. You might prefer using parentheses and
semicolons, as I do:
-- (not tested)
while :: IO Bool -> IO () -> IO ();
while test action = do
{
res <- test;
if res
then do
{
action;
while test action;
}
else return ();
};
--
...and then you can put the whitespace wherever you want.
--
Ashley Yakeley, Seattle WA