Parsing error in Haskell2010

Dear Cafe, I recently ran into a Haskell2010 parsing error with code that parses just fine under Haskell98, and it seems to me that this might be an unintended consequence. Briefly, I have runModel :: StdGen -> Model () -> Result where Model is a monadic type, and then my main was main :: IO () main = do gen <- getStdGen let log = runModel gen $ do initialize 72 report replicateM_ 50 $ do replicateM_251 migrate report putStr . format $ log Haskell 2010 doesn't like the additional level of indentation after the "let log" line. If I pull the content of the "do" into a separate definition, so this becomes let log = runModel gen simulate the parsing error goes away. Questions: 1) Is this intended? 2) Can this code be formatted in a way to make Haskell 2010 happy? Many thanks. Peace, Stu

On Tue, 18 Nov 2014 17:45:55 +0100, Stuart A. Kurtz
where Model is a monadic type, and then my main was
main :: IO () main = do gen <- getStdGen let log = runModel gen $ do initialize 72 report replicateM_ 50 $ do replicateM_251 migrate report putStr . format $ log
Haskell 2010 doesn't like the additional level of indentation after the "let log" line. [...] 2) Can this code be formatted in a way to make Haskell 2010 happy?
The lines after the let must be indented more: main :: IO () main = do gen <- getStdGen let log = runModel gen $ do initialize 72 report replicateM_ 50 $ do replicateM_251 migrate report putStr . format $ log Regards, Henk-Jan van Tuyl -- Folding@home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://folding.stanford.edu/ http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming --

To quote the GHC manual: In Haskell 98 mode and by default (but not in Haskell 2010 mode), GHC is a little less strict about the layout rule when used in do expressions. Specifically, the restriction that "a nested context must be indented further to the right than the enclosing context" is relaxed to allow the nested context to be at the same level as the enclosing context, if the enclosing context is a do expression. This behaviour is controlled by the NondecreasingIndentation extension. On 18/11/14 18:45, Stuart A. Kurtz wrote:
Dear Cafe,
I recently ran into a Haskell2010 parsing error with code that parses just fine under Haskell98, and it seems to me that this might be an unintended consequence.
Briefly, I have
runModel :: StdGen -> Model () -> Result
where Model is a monadic type, and then my main was
main :: IO () main = do gen <- getStdGen let log = runModel gen $ do initialize 72 report replicateM_ 50 $ do replicateM_251 migrate report putStr . format $ log
Haskell 2010 doesn't like the additional level of indentation after the "let log" line. If I pull the content of the "do" into a separate definition, so this becomes
let log = runModel gen simulate
the parsing error goes away.
Questions:
1) Is this intended? 2) Can this code be formatted in a way to make Haskell 2010 happy?
Many thanks.
Peace,
Stu
participants (3)
-
Henk-Jan van Tuyl
-
Roman Cheplyaka
-
Stuart A. Kurtz