Frederik Vreys
Frederik Vreys

Reputation: 11

Haskell syntax error: unexpected `;' possibly due to bad layout

For quite some time now I have been receiving this error on the fourth line : Syntax error in declaration (unexpected `;', possibly due to bad layout) In the following code snippet:

import Data.Maybe    

leesIngrediënten:: Int->[[Char]]->[Int]->[Maybe [Char]]->[[Char]]->([Int], [Maybe [Char]], [[Char]])
leesIngrediënten 0 _ hoevs eenhs naams = (hoevs, eenhs, naams)
leesIngrediënten n (line:lines) hoevs eenhs naams =
                 let 
                     (hoev, eenh, naam) = leesLijn line
                     in  
                       leesIngrediënten (n-1) lines (hoev:hoevs) (eenh:eenhs) (naam:naams)

After searching on the internet I found what the error meant, but the point is I don't see my mistake. (probably because I wrote the code)

The weird thing is, Hugs is the one complaining where GHCi has nothing to complain.

Thanks in advance!

Upvotes: 1

Views: 594

Answers (2)

R4y
R4y

Reputation: 3

It really looks like the the Problem comes with the Unicode identifiers. When I run your code i get

3:12: lexical error (UTF-8 decoding error)

But it is important if the file is an already compiled one or not. If its an exe, dont use runhaskell. That could cause the Problem too. And a little hint for the future, your code is much easier to read, when you use more spaces between words and punctuation marks.

Upvotes: 0

sth
sth

Reputation: 229754

According to https://www.haskell.org/hugs/pages/users_guide/haskell98.html, Hugs doesn't support Unicode identifiers. This probably leads to the syntax error.

Upvotes: 5

Related Questions