notcpp: Avoiding the C preprocessor via cunning use of Template Haskell

[ bsd3, library, template-haskell ] [ Propose Tags ] [ Report a vulnerability ]

notcpp is a library that attempts to provide an alternative to using CPP as a mechanism for conditional compilation. It provides facilities for determining if specific names or class instances exist and responding accordingly.

When a value or class instance appears between minor releases of a third-party package, a common way of dealing with the problem is to use CPP to conditionally use one block of code or another. The trouble with CPP is it's hard to statically analyse: tools based on haskell-src-exts will outright refuse to parse it, for example. It turns out Template Haskell will do the same job in some cases.

notcpp is largely a proof-of-concept, experimental package: you are welcome to use it if it suits you, but it may be liable to change suddenly.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.0.1, 0.1, 0.1.0.1, 0.2, 0.2.0.1, 0.2.0.2, 0.2.0.3
Change log ChangeLog
Dependencies base (<5), template-haskell (>=2.5 && <2.11) [details]
Tested with ghc ==7.0.4, ghc ==7.2.2, ghc ==7.4.2, ghc ==7.6.2, ghc ==7.8.2, ghc ==7.10.1
License BSD-3-Clause
Copyright 2012 Ben Millwood
Author Ben Millwood <haskell@benmachine.co.uk>
Maintainer Ben Millwood <haskell@benmachine.co.uk>
Category Template Haskell
Bug tracker https://github.com/benmachine/notcpp/issues
Source repo head: git clone git://github.com/benmachine/notcpp
Uploaded by BenMillwood at 2015-04-11T01:17:31Z
Distributions
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 4900 total (7 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2015-04-11 [all 1 reports]

Readme for notcpp-0.2.0.3

[back to package description]
This package is as much about getting people to think about ways to
avoid using the C preprocessor, which isn't really suited to Haskell and
never has been, as it is about genuinely providing a set of functions
that people will use in production code.

That is to say, it isn't very good.

Areas of future development:
- catering for missing constructors we can't match against and the like
- quasiquoters to make using the thing less painful