0
votes

I created the following code in Haskell:

eqs a b c 
| ((b^2) - (4*a*c)) < 0 = "MESSAGE"
| otherwise =  "x1= " ++ show (sqrt((-b + ((b^2) - (4*a*c))))2*a) ++ "x2= " show (sqrt((-b - ((b^2) - (4*a*c))))2*a)

Why do I get the following error message?

ERROR file:.\file.hs:2 - Syntax error in declaration (unexpected `;', possibly due to bad layout)

1
@Sandeep Biradar: code formatting is for code only. Haskell is not code, it's a proper name. - Mat
@Mat i did it for highlighting it. - Sandeep
There are a whole lot of problems with your code, but none causes the error you quoted. Please post the exact contents of the file you tried to compile. - leftaroundabout
Guards should be indented more: try adding one or two spaces before each |. This will not fix all errors, but let's start with that. - chi
@SandeepBiradar: do not use code formatting for non-code. If normal English needs highlighting, use bold or italics (and use very little of it). No highlighting is necessary here anyway, just proper capitalization. - Mat

1 Answers

1
votes

The unique problem I see in your code is a type error, not the parser error you've posted. The type error is on the following expression:

 (-b + ((b^2) - (4*a*c))))2*a 

I believe that you probably want to use division, so the correct expression should be

 (-b + ((b^2) - (4*a*c)))) / (2*a)

Hope that this can help you. In order to better help you, please consider to post the whole content of your Haskell program file.