
I am trying (and have been for quite some time) to repair a broken Haskell script. I keep getting stuck on Last generator in do {...} must be an expression. I am betting that this is not uncommon. Can someone please help me understand? code5 :: Parser code5 = do dd <- code3 do ddd <- code3 do dddd <- code3 return "ce" code4 :: Parser code4 = do dd <- code3 do dde <- code3 digit ddd <- many (do digit) q <- code5 return (q : "ss") Thanks in advance for helping Matthew

On Fri, 20 Feb 2004, Matthew Morvant wrote:
I am trying (and have been for quite some time) to repair a broken Haskell script.� I keep getting stuck on �Last generator in do {...} must be an expression�.� I am betting that this is not uncommon.� Can someone please help me understand?
code5 :: Parser code5 = do dd <- code3 do ddd <- code3 do dddd <- code3 return "ce"
The author appears to want this (braces and semicolons included for clarity): code5 = do { dd <- code3; ddd <- code3; dddd <- code3; return "ce" } which will assign the results of code3 3 times in succession to dd, ddd, and ddd before returning "ce". Of course, you /could/ just write that as: do {code3; code 3; code 3; return "ce"} Unless I misunderstand the intent here?
code4 :: Parser code4 = do ����������� ����������� dd <- code3 ����������������������� do dde <- code3 ����������������������� ����������� digit ����������������������������������� ddd <- many (do digit) ����������������������������������� q <- code5 ����������������������������������� return (q : "ss")
Attempting to grok this suggests I might. Is code3 supposed to take a parser as a parameter? -- flippa@flippac.org

On Fri, 20 Feb 2004 15:21:37 -0600 Matthew Morvant wrote:
I keep getting stuck on ?Last generator in do {...} must be an expression?.
'do' is for the beginning of a block. It's not needed every time a Parser is mentioned. If you want code5 to consist of 3 code3s, one after another, then you need code5 = do dd <- code3 ddd <- code3 dddd <- code3 return "something" All components of one 'do' (whether the component binds with <-, whether it's a simple expression, or it's a 'let' binding) must be indented the same amount. That is a problem on the pair of lines that mention "dde" and "digit".
code5 :: Parser code5 = do dd <- code3 do ddd <- code3 do dddd <- code3 return "ce"
participants (3)
-
Matthew Morvant
-
Philippa Cowderoy
-
scott@billygoat.org