>FAQ and Things To Watch Out For
You probably omitted the module declaration at the top of the module, which causes the module name to default to Main. In Haskell, the Main module must define a function called main. Admittedly this doesn't make a great deal of sense for an interpreter, but the rule was kept for compatibility with GHC.
Unfortunately not. We haven't implemented it yet. Please compile any offending modules by hand before loading them into GHCi.
For technical reasons, the bytecode compiler doesn't interact well with one of the optimisation passes, so we have disabled optimisation when using the interpreter. This isn't a great loss: you'll get a much bigger win by compiling the bits of your code that need to go fast, rather than interpreting them with optimisation turned on.
That's right. You can always compile a module that uses unboxed tuples and load it into GHCi, however. (Incidentally the previous point, namely that -O is incompatible with GHCi, is because the bytecode compiler can't deal with unboxed tuples).
No, they don't. This is because the Haskell binding to the GNU readline library doesn't support reading from the terminal in a non-blocking way, which is required to work properly with GHC's concurrency model.
This is the defined behaviour of getContents: it puts the stdin Handle in a state known as semi-closed, wherein any further I/O operations on it are forbidden. Because I/O state is retained between computations, the semi-closed state persists until the next :load or :reload command.
You can make stdin reset itself after every evaluation by giving GHCi the command :set +r. This works because stdin is just a top-level expression that can be reverted to its unevaluated state in the same way as any other top-level expression (CAF).