Re: [Haskell-cafe] Parsing error in Haskell2010

Dear Andy,
If that is the actual indentation in the file (and not just one or both of our mail clients breaking it), the problem is that the `let` line needs to start in the same column as the lines with `gen` and `putStr`.
The gen, let, and putStr were properly aligned. After all, it compiled as Haskell98 ;-).
(Also, the inner do-block needs to be indented strictly further than the word `log`, in case it isn't in the original file.)
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? Peace, Stu

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
On Tue, Nov 18, 2014 at 3:01 PM, Stuart A. Kurtz
Dear Andy,
If that is the actual indentation in the file (and not just one or both of our mail clients breaking it), the problem is that the `let` line needs to start in the same column as the lines with `gen` and `putStr`.
The gen, let, and putStr were properly aligned. After all, it compiled as Haskell98 ;-).
(Also, the inner do-block needs to be indented strictly further than the word `log`, in case it isn't in the original file.)
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?
Peace,
Stu
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

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

The first lexeme after let is log. Everything indented same as log (that is, starting at the same column as log) is considered to be bindings inside that let; everything indented more is considered to be continuation of a binding. In your original example, initialize is indented same as log, so ghc tries to parse it as a binding, and fails. The NondecreasingIndentation that I mentioned in the other email relaxes this constraint. On 19/11/14 14:45, Stuart A. Kurtz wrote:
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
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Stuart,
As Roman says, GHC is expecting that everything in that indentation level
will be a new binding, that's te reason of giving the error *on the next
line*, is because it was still *looking* for a `=` when it found `report`.
As of why Haskell2010 changed this behaviour, I have no idea, but I'm sure
the people behind this had good reasons (I find Haskell2010's behaviour
more desirable).
You can always use the `NondecreasingIndentation` suggested by Roman.
Cheers,
Matteo
On Wed, Nov 19, 2014 at 9:26 AM, Roman Cheplyaka
The first lexeme after let is log. Everything indented same as log (that is, starting at the same column as log) is considered to be bindings inside that let; everything indented more is considered to be continuation of a binding.
In your original example, initialize is indented same as log, so ghc tries to parse it as a binding, and fails.
The NondecreasingIndentation that I mentioned in the other email relaxes this constraint.
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
On 19/11/14 14:45, Stuart A. Kurtz wrote: 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 <
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
matteo.ferrando2@gmail.com> wrote: 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
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
Matteo Ferrando
-
Roman Cheplyaka
-
Stuart A. Kurtz