
Dear Matteo, The surprise for me comes from the idea that the *amount* of indentation matters on establishing a new block, which hasn't been my experience with Haskell's offside rule before, although I tend to be 4-ist when it comes to indenting, and it's possible that this behavior has kept me on the good side thus far of rules that I wasn't aware of. So my instinct would have been to indent the code the way you've done below, but only if there were additional let bindings. It is particularly confusing that the error is reported as being on the "report" line, which seems to imply that the indentation of the previous line was ok (and therefore that the implicit block of which it is a part had been set up based on the do). It's nothing new to see syntax errors reported a line late -- the Pascal compilers did that! -- but unexpected here because GHC seems quite good about locating errors. Peace, Stu
On Nov 18, 2014, at 11:16 PM, Matteo Ferrando
wrote: This seems to be the issue. Haskell98 didn't require this, Haskell2010 does, and this seems less desirable to me. Isn't it reasonable to assume that the it's the do that dominates syntactically here, and not the let?
No, so you can do stuff like:
main = do gen <- getStdGen let log = runModel gen $ do initialize 72 report replicateM_ 50 $ do replicateM_251 migrate report log' = runModel gen $ do initialize 42 report replicateM_ 50 $ do replicateM_251 migrate report log'' = runModel gen $ do initialize 42 report replicateM_ 50 $ do replicateM_251 migrate report putStr . format $ log putStr . format $ log' putStr . format $ log''
Defining `log`, `log'` and `log''` with the same `let`.
Cheers,
Matteo