Home > front end >  Haskell lambda function - parse error on input ‘)’
Haskell lambda function - parse error on input ‘)’

Time:05-12

I have the following code in Haskell and I want to change the line

toNanoStmt (VarDeclStmt _ array)= SeqList (toNanoStmt (map (\(VarDecl _ (Id a x) (Just exp))) array ))

Basically I want to use VarDeclStmt by creating a sequence of assign statements. A SeqList takes a list of statements. I have the list of VarDecls! And I have again use a map to convert the varDeclArr to a list of assignments. But am getting this error:

parse error on input ‘)’

CodePudding user response:

Your lambda-expression has no body.

After parameters, there has to come a right arrow -> followed by the body, for example:

addTwo = (\x -> x   2)

So in your case you need to do something like this:

toNanoStmt (VarDeclStmt _ array)= SeqList (toNanoStmt (map (\(VarDecl _ (Id a x) (Just exp)) -> <body goes here>) array ))
  • Related