The base-feature-macros package

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain]

This provides a set of feature macros describing features of base in a semantic way.

See <base-feature-macros.h> for the set of currently provided macros.

In order to use the CPP header provided by this package, add this package as a dependency to your .cabal file, i.e.

build-depends: base-feature-macros: >= 0.1 && < 0.2

while making sure that the version specified as lower bound defines the feature-macros your code tests for. This is particularly important as CPP will implicitly treat undefined CPP macros as having the value 0. See also GNU CPP/CC's -Wundef warning to detect such errors; or starting with GHC 8.2, -Wcpp-undef can be used:

if impl(ghc >= 8.2)
    ghc-options: -Wcpp-undef

Then in your code, you can include and use the <base-feature-macros.h> header like so

module M where

#include <base-feature-macros.h>

#if !HAVE_FOLDABLE_TRAVERSABLE_IN_PRELUDE
import Data.Foldable (Foldable (..))
import Prelude       hiding (foldr, foldr1)
#endif
#if !HAVE_MONOID_IN_PRELUDE
import Data.Monoid hiding ((<>))
#endif

This package is inspired by the blogpost "Make macros mean something – readable backwards compatibility with CPP".

Properties

Versions0.1, 0.1.0.1, 0.1.0.1
Change logChangeLog.md
Dependenciesbase (>=4.3 && <4.11) [details]
LicenseBSD3
AuthorHerbert Valerio Riedel
Maintainerhvr@gnu.org
CategoryDevelopment
Bug trackerhttps://github.com/hvr/base-feature-macros/issues
Source repositoryhead: git clone https://github.com/hvr/base-feature-macros.git
UploadedMon Jun 5 22:08:49 UTC 2017 by HerbertValerioRiedel

Downloads

Maintainers' corner

For package maintainers and hackage trustees