[Haskell-cafe] Replacing CPP [was: Current status of Mavericks CPP]

Ben Franksen ben.franksen at online.de
Wed Apr 16 12:48:55 UTC 2014


Sven Panne wrote:
> 2014-04-16 12:34 GMT+02:00 Ben Franksen <ben.franksen at online.de>:
>> [...]Has nobody ever written a paper about how to extend Haskell with the
>> [few
>> features we actually need from CPP? I think general macro replacement
>> like CPP offers is not on the list, right? IIUC, CPP is used in Haskell
>> libraries almost exclusively for conditional compilation. [...]
> 
> Nope:
> https://github.com/haskell-opengl/OpenGLRaw/blob/master/include/HsOpenGLRaw.h

Yes, I expected there are libraries out there that use more of CPP's 
features, just not very many. And note, I'm not proposing to deprecate CPP 
any time soon, just to offer a sane(r) alternative ASAP.

> Perhaps some template Haskell magic might work nowadays, bug there was
> no TH at all when the bindings started, and I am not sure if I should
> tie this package to GHC.

Agreed, you should not have to.

> The real solution is generating the binding
> via the OpenGL XML spec, anyway, but I somehow have to do some real
> (non-Haskell) work for real money. ;-)

I can relate to that, believe me. In the meantime, CPP will stay around for 
some time, for special use cases like yours. Its use would just no longer be 
encouraged for cases where it is not needed.

BTW, I do not think that mixing conditional compilation and general macro 
replacements in the same tool is particularly good design. That CPP is used 
for both is an unfortunate accident of history and we should not try to 
repeat that.

> My point is: Do we really know that conditional compilation is *the*
> use case? I remember that in ancient days macros were used to generate
> instances etc. Make things as simple as possible, but not simpler.

Well, what everybody said whenever the question came up in the last years 
was that this is the killer feature we absolutely can't live without.

But you are right, we should find out!

There are people on this list who grep the whole of hackage in a matter of 
minutes whenever someone (seriously) proposes some non-compatible change to 
see who many libraries would be affected. (Any volunteers?) My guess is that 
no more than a few hands full of the hackage packages use more than 
conditional compilation, but I may be completely wrong about that.

Cheers
Ben
-- 
"Make it so they have to reboot after every typo." -- Scott Adams




More information about the Haskell-Cafe mailing list