11 Feb
2012
11 Feb
'12
11:17 a.m.
Hi I noticed that jhc is not checking what the type of the main function is. In particular, it rejects this module:
main = return ()
because the inferred type, Monad m => m () is not monomorphic. This may typically happen if the most general type for main is MonadIO m => m (). On the other hand, the following module is accepted:
main :: [()] main = return ()
The resulting program does not crash (as I had expected!) but prints [()] instead. In any case, according to the Haskell 98 Report (sec. 5), main has to be "a computation of type IO t, for some type t". I'm attaching a patch that enforces this (I think) by unifying, during the type-checking, the type of the main function with IO t. Daniel
5083
Age (days ago)
5083
Last active (days ago)
0 comments
1 participants
participants (1)
-
Daniel Gorín