Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove instances and data types #21

Merged
merged 1 commit into from
Apr 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 8 additions & 25 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
# A compatibility layer for `base`
## Scope

The scope of `base-compat` is to provide functions, data types and instances
available in later versions of base to a wider (older) range of compilers.
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:** `base-compat` never redefines data types or classes, it only adds
missing functions, data types and instances. This implies that `base-compat`
is a best-effort approach. If a data type or class is changed in a backward
incompatible way, `base-compat` may not be able to address this.
Note that `base-compat` does not add any orphan instances. There is a separate
package [`base-orphans`](https://github.com/haskell-compat/base-orphans) for
that.

## Basic usage

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

```
build-depends: base == 4.*
, base-compat >= 0.6
, base-compat >= 0.8.0
```

Then, lets say you want to use the `isRight` function introduced with
Expand Down Expand Up @@ -91,23 +90,8 @@ So far the following is covered.
* `Text.Read.Compat.readEither`
* `System.Environment.Compat.lookupEnv`
* `Data.Monoid.Compat.<>`
* Added `Eq` and `Ord` instances for `Contro.Exception.ErrorCall`
* Added `Eq`, `Ord`, `Read`, and `Show` instances for data types in `GHC.Generics`
* Added `Monoid`, `Eq`, `Ord`, `Read`, and `Show` instances for `Const`
* Added `Read` and `Show` instances for `Down`
* Added `Eq`, `Ord`, `Read`, and `Show` instances for `ZipList`
* Added `Monad` instance for `WrappedMonad`
* Added `Data` and `IsList` instances for `Version`
* Added `bool` function to `Data.Bool.Compat`
* Added `isLeft` and `isRight` to `Data.Either.Compat`
* `Bits` instance for `Bool`
* `Generic` instance for `All`, `Any`, `Const`, `Dual`, `Endo`, `First`, `Last`, `Product`, `Sum`, `WrappedArrow`, `WrappedMonad`, and `ZipList`
* `Generic1` instance for `Const`, `Dual`, `First`, `Last`, `Product`, `Sum`, `WrappedArrow`, `WrappedMonad`, and `ZipList`
* `Foldable` instance for `Either`, `(,)` and `Const`
* `Functor` instance for `ArgOrder`, `OptDescr`, and `ArgDescr`
* `Num` instance for `Sum` and `Product`
* `Storable` instance for `Complex` and `Ratio`
* `Traversable` instance for `Either`, `(,)` and `Const`
* Added `withMVarMasked` function to `Control.Concurrent.MVar.Compat`
* Added `(<$!>)` function to `Control.Monad.Compat`
* Added `($>)` and `void` functions to `Data.Functor.Compat`
Expand All @@ -118,8 +102,6 @@ So far the following is covered.
* `traceId`, `traceShowId`, `traceM`, and `traceShowM` functions to `Debug.Trace.Compat`
* `calloc` and `callocBytes` functions to `Foreign.Marshal.Alloc.Compat`
* `callocArray` and `callocArray0` functions to `Foreign.Marshal.Array.Compat`
* Backported `Alt` data type to `Data.Monoid`
* Backported `Down` data type to `Data.Ord`
* Added `Data.List.Compat.scanl'`

## Supported versions of GHC/base
Expand Down Expand Up @@ -153,6 +135,7 @@ the output of

ghc --show-iface Prelude.hi

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

./check-Prelude.sh
13 changes: 2 additions & 11 deletions base-compat.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ library
-Wall
build-depends:
base == 4.*
, ghc-prim
, setenv
ghc-options:
-fno-warn-duplicate-exports
Expand All @@ -36,30 +35,22 @@ library
src

exposed-modules:
Prelude.Compat
Control.Applicative.Compat
Control.Concurrent.MVar.Compat
Control.Exception.Compat
Control.Monad.Compat
Data.Bits.Compat
Data.Bool.Compat
Data.Either.Compat
Data.Foldable.Compat
Data.Function.Compat
Data.Functor.Compat
Data.List.Compat
Data.Monoid.Compat
Data.Ord.Compat
Data.Traversable.Compat
Data.Version.Compat
Debug.Trace.Compat
Foreign.Compat
Foreign.Marshal.Compat
Foreign.Marshal.Alloc.Compat
Foreign.Marshal.Array.Compat
Foreign.Storable.Compat
GHC.Generics.Compat
System.Console.GetOpt.Compat
Foreign.Marshal.Compat
Prelude.Compat
System.Environment.Compat
System.Exit.Compat
Text.Read.Compat
Expand Down
3 changes: 0 additions & 3 deletions check/Data.Traversable.Compat.check.hs

This file was deleted.

10 changes: 0 additions & 10 deletions check/Data.Traversable.Compat.index

This file was deleted.

10 changes: 0 additions & 10 deletions check/Data.Traversable.Compat.types

This file was deleted.

4 changes: 3 additions & 1 deletion mk-index.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -o errexit

runhaskell dumpindex.hs Prelude.Compat | sort > check/Prelude.Compat.index
runhaskell dumpindex.hs Data.Foldable.Compat | sort > check/Data.Foldable.Compat.index
runhaskell dumpindex.hs Data.Traversable.Compat | sort > check/Data.Traversable.Compat.index
runhaskell dumpindex.hs Data.List.Compat | sort > check/Data.List.Compat.index
4 changes: 3 additions & 1 deletion run-check.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash

set -o errexit

runhaskell dumptypes.hs Prelude.Compat | typediff check/Prelude.Compat.types -
runhaskell dumptypes.hs Control.Monad.Compat | typediff check/Control.Monad.Compat.types -
runhaskell dumptypes.hs Data.Foldable.Compat | typediff check/Data.Foldable.Compat.types -
runhaskell dumptypes.hs Data.Traversable.Compat | typediff check/Data.Traversable.Compat.types -
runhaskell dumptypes.hs Data.List.Compat | typediff check/Data.List.Compat.types -
49 changes: 0 additions & 49 deletions src/Control/Applicative/Compat.hs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Control/Concurrent/MVar/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Control.Concurrent.MVar.Compat (
) where
import Control.Concurrent.MVar as Base

#if !MIN_VERSION_base(4,7,0)
#if !(MIN_VERSION_base(4,7,0))
import Control.Exception (mask_, onException)
import Control.Monad (return)
import Data.Function (($))
Expand Down
15 changes: 0 additions & 15 deletions src/Control/Exception/Compat.hs

This file was deleted.

12 changes: 6 additions & 6 deletions src/Control/Monad/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Control.Monad.Compat (
module Base
, Monad(..)
, MonadPlus(..)
#if !MIN_VERSION_base(4,8,0)
#if !(MIN_VERSION_base(4,8,0))
, foldM
, foldM_
, forM
Expand All @@ -20,7 +20,7 @@ module Control.Monad.Compat (
, (<$!>)
#endif

#if !MIN_VERSION_base(4,5,0)
#if !(MIN_VERSION_base(4,5,0))
, void
#endif
) where
Expand All @@ -42,19 +42,19 @@ import Control.Monad as Base hiding (
, unless
, when
)
import Control.Applicative.Compat (Alternative(..))
import Control.Applicative (Alternative(..))
import Data.Foldable.Compat
import Data.Traversable.Compat
import Data.Traversable
import Prelude.Compat
#endif

#if !MIN_VERSION_base(4,3,0)
#if !(MIN_VERSION_base(4,3,0))
-- | @'void' value@ discards or ignores the result of evaluation, such as the return value of an 'IO' action.
void :: Functor f => f a -> f ()
void = fmap (const ())
#endif

#if !MIN_VERSION_base(4,8,0)
#if !(MIN_VERSION_base(4,8,0))
-- | Conditional execution of 'Applicative' expressions. For example,
--
-- > when debug (putStrLn "Debugging")
Expand Down
40 changes: 0 additions & 40 deletions src/Data/Bits/Compat.hs

This file was deleted.

18 changes: 5 additions & 13 deletions src/Data/Bool/Compat.hs
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
{-# LANGUAGE CPP, NoImplicitPrelude #-}
module Data.Bool.Compat (
-- * Booleans
Bool(..),
-- ** Operations
(&&),
(||),
not,
otherwise,
bool,
) where
module Base
, bool
) where

import Data.Bool

#if !MIN_VERSION_base(4,7,0)
import Data.Bits.Compat ()
import Data.Bool as Base

#if !(MIN_VERSION_base(4,7,0))
-- | Case analysis for the 'Bool' type.
-- @bool a b p@ evaluates to @a@ when @p@ is @False@, and evaluates to @b@
-- when @p@ is @True@.
Expand Down
3 changes: 1 addition & 2 deletions src/Data/Either/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ module Data.Either.Compat (
) where
import Data.Either as Base

#if !MIN_VERSION_base(4,7,0)
#if !(MIN_VERSION_base(4,7,0))
import Data.Bool (Bool(..))
import Data.Traversable.Compat ()

-- | Return `True` if the given value is a `Left`-value, `False` otherwise.
--
Expand Down
Loading