[Haskell-cafe] Parsing error in Haskell2010

Stuart A. Kurtz stuart at cs.uchicago.edu
Tue Nov 18 16:45:55 UTC 2014


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



More information about the Haskell-Cafe mailing list