lundi 26 octobre 2020

parse error on input ‘if’ in Haskell code

I'm trying to use Haskell and I am new to this programming language. I was running this code which was intended to print Greater when the function had an integer greater than 50 and Less when the function was run with an integer less than 50.

printLessorGreater :: Int -> String
    if a > 50
        then return ("Greater") 
        else return ("Less")
    
main = do
    print(printLessorGreater 10)

However, when I ran the code, it gave me this error:

main.hs:2:5: error: parse error on input ‘if’

I went to line 5 and there was nothing in the line. Does anyone know how to solve this error at this point? I would appreciate it!

Aucun commentaire:

Enregistrer un commentaire