I have the following function in my Haskell file:
notFound :: () -> IO ()
notFound = putStr "Sorry, your command could not be found"
That function doesn't compile. This is the compile error I get:
todos.hs:27:12:
Couldn't match expected type ‘() -> IO ()’ with actual type ‘IO ()’
Possible cause: ‘putStr’ is applied to too many arguments
In the expression: putStr "Sorry, your command could not be found"
In an equation for ‘notFound’:
notFound = putStr "Sorry, your command could not be found"
But the following function does:
notFound :: IO ()
notFound = putStr "Sorry, your command could not be found"
Question:
From my understanding of the type signature, it would seem that these are the same, that ()
means that no arguments are passed into the function. Is that not the case? If not, what does ()
in a function signature mean then?