
Nicola Gigante
Il giorno 09/gen/2015, alle ore 14:55, Johan Tibell
ha scritto: Hi,
(This was initially written as a Google+ post, but I'm reposting it here to raise awareness of the issue.)
The amount of CPP we have to use in Haskell is getting a bit out of hand. Here are the number of modules, per library, that use CPP for some of the libraries I maintain:
[snip]
Hi
I’m an outsider so this could probably sound ingenuous but, why not thinking about an in-language feature to solve the problems addressed by CPP?
This might be a good time to bring in the data point provided by Rust [1], where the attribute system to allow conditional compilation. For instance, #[cfg(not(a_feature))] pub fn my_function() { ... } #[cfg(a_feature)] pub fn my_function() { ... } The build system can then detect whether the feature in question is available, and potentially pass `-f a_feature` to the compiler. `cfg` items can also have string values which can be tested for equality (although I think they intend on extending this at some point). This works well for them as it is flexible and fits nicely into the language, reusing the attribute syntax that Rust users are already familiar with. The closest thing Haskell has to this is the conventional `{-# ... #-}` pragma syntax, but leveraging this would almost certainly require compiler support and a language extension. Cheers, - Ben [1] http://doc.rust-lang.org/reference.html#conditional-compilation