|
Re: The simplest program: msg#00039lang.haskell.glasgow.bugs
Axel Simon wrote: This bug is older! ghc 5.04 does not enforce that the return type of main I don't know about an exception on termination (Is it a known bug? If not, it should be reported), but returning anything is allowed. The Haskell Report, section 5, says: A Haskell program is a collection of modules, one of which, by convention, must be called Main and must export the value main. The value of the program is the value of the identifier main in module Main, which must be a computation of type IO t for some type t (see Section 7). When the program is executed, the computation main is performed, and its result (of type t) is discarded. The problem with that no-op program is that the type checker doesn't seem to know that main has to be in the IO monad. On the other hand... > module Main where > main :: Monad m => m () > main = return () is legal according to both GHC 5.04 and 5.05. Now I'm beginning to see why GHC complains. It would be nice, though, if "main = return ()" was legal without additional type signatures. I've been bitten by this before: I wrote some datatypes and functions in a "Main" module, but I left the main action empty at first. Then I just wanted to check syntax and typing and got a strange error message... Cheers, Wolfgang
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | The simplest program, Wolfgang Thaller |
|---|---|
| Next by Date: | Profiling and ext-core, Kirsten Chevalier |
| Previous by Thread: | Re: The simplest program, Axel Simon |
| Next by Thread: | RE: The simplest program, Simon Peyton-Jones |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |