Simon Peyton-Jones wrote:
> One solution is to add
> macros (presumably in a more hygienic form than cpp), but I'm reluctant
> to advocate that, because macros undoubtedly do overlap with functions.
You don't need macros. (For speed purposes inline functions are obviously
better.) All you need are (a) a way of defining a constant value (restricted
to type Integer or Bool say) in one file so that it can be used in another file;
(b) a type of compile-time if statement which will branch on simple arithmetic
and boolean expressions in constant values and constants, which doesn't typecheck
the branch which isn't taken. For example, this is what Java provides and
I think it's not too bad. (In Java the compile-time "if" is indistinguishable
from the normal one; I'd rather for Haskell it was called something different,
like _if.) I think you could get such a solution to work; it wouldn't
be terribly elegant, but it would be a lot more elegant than the current
combination of Haskell + CPP.