f :: t
can be either the expression (f :: t) or the start of a function
declaration. One way to resolve this would be to treat f :: t as a
function type specification if it's followed by something of the form
f = ..., and as an expression otherwise. The only difference with the
current code is that stuff like
f :: Int
g = 3
f = 3
would get through the parser. Currently, it fails at parse time
because f :: t must be followed by the definition of f. Of course,
even if that got through the parser it would currently fail at type
inference time because f doesn't have a type when f :: Int gets
evaluated.
Time for sleep.
Geoffrey
I'm not convinced we need to support top-level statements. In the main
module, clearly they add no value. In other modules, they may be ill-advised,
but the same effect can be achieved with top-level assignments "_ = f" anyway.
I'd been assuming that main would vanish entirely, a la perl or python. _ = f certainly works, but it'd be odd if we allowed just f inside functions but not outside. It also hides whether the return type is unit or not.
Geoffrey