| Here is some strange question:
|   how to force the compiler to evaluate some things more statically
|   and to convert some run-time errors into the compile-time ones?

Not strange at all.  It would be quite reasonable to have some way
to tell the compiler 'evaluate this to a static value'.   I'd suggest
doing it via a pseudo-function
        static :: a -> a

which behaved like the identity function, except that it evaluated
its argument rather eagerly at compile time.  Implementing it would
be a little delicate (because inlining is already a delicate part of
GHC) but would not take much code.


About converting run-time to compile-time errors, as others have
said, some functions are legitimately bottom.  But think about assertions:

        f x = assert (p x) (...x...)

where   assert :: Bool -> a -> a

If the boolean is False, you get an error message pinpointing the
line in the file.  Now, a function with an assert that always fails
is indeed a good candidate for a compile-time error message.

Again, this is a modest extension, and GHC already has a little-known
assert feature.


But both of these are yet more non-standard features to add.
Life is short.  Are these features that would be useful to lots of people?

Simon


Reply via email to