import System.IO
import Data.Char
edastaNr n
= do
putStrLn "Anna rida:"
line <- getLine
if null line
then return ()
else do return length(line)
can anybody explain why the last line is incorrect and how it is possible to fix it? I do not realize.. error is:
Couldn't match expected type `IO ()' with actual type `[a0] -> Int'
You’re missing parentheses.
However, there are type errors as well. What is the type of your
edasaNrfunction?It must do some IO and return an
Int, when given an argument.So it would be better written as:
which also reveals that you don’t use the
nargument (so it can have any type).