[Haskell-cafe] Help a Newbie

scott at billygoat.org scott at billygoat.org
Fri Feb 20 14:26:37 EST 2004


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"


More information about the Haskell-Cafe mailing list