This error message means simply that the compiler didn't find a definition of your function main
.
To run your compiled program, rather than interact with it in ghci (which I'd recommend you do as a beginner), you need main::IO ()
.
If you don't give your module a name, it automagically does the equivalent of inserting module Main where
at the top of your file.
I can't think of any way to produce this error other than to
- accidentally comment out main with
--
or {-
other comment syntax -}
- spell the word
main
incorrectly
- accidentally compile an empty file.
(
Although your question appears to show incorrect indentation, that's because this site does not treat tabs as 8 characters wide. I suspect you indented the main
by four spaces to get it to format as code in your question. In any case the compiler didn't give an error message consistent with an indentation error.
I'd like to recommend you use spaces rather than tabs for indentation, as it's unfailingly irritating to have to debug the whitespace of your program.
Most editors can be configured to turn a tab key press into an appropriate number of spaces, giving you the same line-it-up functionality with none of the character count discrepancies.
)