Parse error but no mismatched brackets or incorrect indentation


#1

Hello, I’m getting this error

Screenshot_2019-09-13_16-37-47

Where my code is

 padron_Docente ((Per nom dni año rol):xs) = if rol == Docente _ then (nom, dni):padron_Docente xs 

If i add more lines to the document the error goes to the last line, if i comment or delete that line of code the error goes away but if i write it again the error comes back. I’m using notepadqq but also tried saving the file with mousepad and the error still there.
I have been editting the document the whole day and no problems until now.

Thanks in advance


#2

your If Expression is missing the else clause. In Haskell, if is always of the form if <predicate> then <expr> else <expr>.


#3

Oh… well that was dumb from my part. Thank you


#4

@Franpg995 You may be interested to know the reason why every if expression must be accompanied by an else. (Or you may not, but I’ll explain just in case!) In other languages, an if encloses a block, so you can just skip execution of the block if the condition isn’t satisfied. But in Haskell, an if is an expression, which evaluates to a value, so you have to have a value to use when the condition isn’t satisfied. (For example, what would be the value of if False then 1?)