The base-compat package

[Tags: library, mit]

Provides functions available in later versions of base to a wider range of compilers, without requiring you to use CPP pragmas in your code. See the README for what is covered. Also see the changelog for recent changes.

Note that base-compat does not add any orphan instances. There is a separate package base-orphans for that.


[Skip to ReadMe]

Properties

Versions0.0.0, 0.1.0, 0.1.0.1, 0.2.0, 0.2.0.1, 0.2.0.2, 0.2.1, 0.3.0, 0.4.0, 0.4.1, 0.4.2, 0.5.0, 0.6.0, 0.7.0, 0.7.1, 0.8.0, 0.8.0.1, 0.8.1, 0.8.1.1, 0.8.2 (info)
Change logCHANGES.markdown
Dependenciesbase (>=4.3 && <5), unix [details]
LicenseMIT
Copyright(c) 2012-2015 Simon Hengel, (c) 2014 João Cristóvão, (c) 2015 Ryan Scott
AuthorSimon Hengel <sol@typeful.net>, João Cristóvão <jmacristovao@gmail.com>, Ryan Scott <ryan.gl.scott@ku.edu>
MaintainerSimon Hengel <sol@typeful.net>, João Cristóvão <jmacristovao@gmail.com>, Ryan Scott <ryan.gl.scott@ku.edu>
CategoryCompatibility
Source repositoryhead: git clone https://github.com/haskell-compat/base-compat
UploadedWed May 13 06:37:14 UTC 2015 by ryanglscott
DistributionsDebian:0.8.2, LTSHaskell:0.8.2, NixOS:0.8.2, Stackage:0.8.2
Downloads7094 total (579 in last 30 days)
Votes
1 []
StatusDocs available [build log]
Last success reported on 2015-05-13 [all 1 reports]

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for base-compat-0.8.2

A compatibility layer for base Hackage version Build Status

Scope

The scope of base-compat is to provide functions available in later versions of base to a wider (older) range of compilers.

In addition, successful library proposals that have been accepted to be part of upcoming versions of base are also included. This package is not intended to replace base, but to complement it.

Note that base-compat does not add any orphan instances. There is a separate package base-orphans for that.

Basic usage

In your cabal file, you should have something like this:

  build-depends:      base              >= 4.3
                    , base-compat       >= 0.8.0

Then, lets say you want to use the isRight function introduced with base-4.7.0.0. Replace:

import Data.Either

with

import Data.Either.Compat

Note (1): There is no need to import both unqualified. The .Compat modules re-exports the original module.

Note (2): If a given module .Compat version is not defined, that either means that:

Using Prelude.Compat

If you want to use Prelude.Compat (which provides all the AMP/Traversable/Foldable changes from base-4.8.0.0), it's best to hide Prelude, e.g.:

import Prelude ()
import Prelude.Compat

main :: IO ()
main = mapM_ print (Just 23)

Alternatively, you can use the NoImplicitPrelude language extension:

{-# LANGUAGE NoImplicitPrelude #-}
import Prelude.Compat

main :: IO ()
main = mapM_ print (Just 23)

Note that we use

mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()

from Data.Foldable here, which is only exposed from Prelude since base-4.8.0.0.

Using this approach allows you to write code that works seamlessly with all versions of GHC that are supported by base-compat.

What is covered

So far the following is covered.

For compatibility with the latest released version of base

Supported versions of GHC/base

Patches are welcome; add tests for new code!

Development

For Prelude.Compat there is an Prelude.index file that was generated from the output of

ghc --show-iface Prelude.hi

To verify that Prelude.Compat matches the specification given in Prelude.types run:

./check-Prelude.sh