I have three files (Play.hs, Sudoku.hs and Nim.hs), and each one of those files has a main.
I want to make a main in Play.hs to run one of those games (either Nim or Sudoku), like this:
main :: IO ()
main = do
putStrLn "1-Sudoku"
putStrLn "2-Nim"
putStrLn "choice----->"
let x=getLine
if x==1 then
....
else
...
You may call the
mainvalue from other modules just fine, as long as add the linemodule Nim whereto the top ofNim.hs, and similarly forSudoku.hs.Of course, if you have more than one
mainin scope, there will be ambiguity; but you can deal with ambiguity in the same way formainas you do for other names by qualifying them...and if you're in the interpreter, start your program with
Play.main.