Commit 575524f7 authored by Oleg Grenrus's avatar Oleg Grenrus
Browse files

Add Distribution.Compat.Prelude, and use it in .Graph

parent ad6af39f
......@@ -378,6 +378,7 @@ library
......@@ -80,20 +80,18 @@ module Distribution.Compat.Graph (
) where
import qualified Prelude as Prelude
import Prelude hiding (lookup, null)
import Prelude ()
import qualified Distribution.Compat.Prelude as Prelude
import Distribution.Compat.Prelude hiding (lookup, null, empty)
import Data.Graph (SCC(..))
import qualified Data.Graph as G
import Data.Map (Map)
import qualified Data.Map as Map
import qualified Data.Array as Array
import Data.Array ((!))
import qualified Data.Tree as Tree
import Data.Either (partitionEithers)
import Data.Typeable (Typeable)
import qualified Data.Foldable as Foldable
import Control.DeepSeq (NFData(..))
import Distribution.Compat.Binary (Binary(..))
-- | A graph of nodes @a@. The nodes are expected to have instance
-- of class 'IsNode'.
#ifdef MIN_VERSION_base
#define MINVER_base_48 MIN_VERSION_base(4,8,0)
#define MINVER_base_47 MIN_VERSION_base(4,7,0)
#define MINVER_base_46 MIN_VERSION_base(4,6,0)
#define MINVER_base_48 (__GLASGOW_HASKELL__ >= 710)
#define MINVER_base_47 (__GLASGOW_HASKELL__ >= 708)
#define MINVER_base_46 (__GLASGOW_HASKELL__ >= 706)
module Distribution.Compat.Prelude (
-- * Prelude
-- Prelude is re-exported, following is hided:
module BasePrelude,
#if !MINVER_base_48
-- * base 4.8 shim
Applicative(..), (<$), (<$>),
-- * Common type-classes
Semigroup (..),
gmappend, gmempty,
NFData (..),
Binary (..),
Alternative (..),
MonadPlus (..),
-- * Some types
-- * Data.Maybe
catMaybes, mapMaybe,
maybeToList, listToMaybe,
isNothing, isJust,
-- * Data.List
isPrefixOf, isSuffixOf,
intercalate, intersperse,
sort, sortBy,
nub, nubBy,
-- * Data.Foldable
Foldable, foldMap, foldr,
null, length,
find, foldl',
traverse_, for_,
-- * Data.Traversable
Traversable, traverse, sequenceA,
-- * Control.Arrow
-- * Control.Monad
liftM, liftM2,
unless, when,
ap, void,
foldM, filterM,
-- * Data.Char
isSpace, isDigit, isUpper, isAlpha, isAlphaNum,
chr, ord,
toLower, toUpper,
-- * Text.PrettyPrint
) where
-- We also could hide few partial function
import Prelude as BasePrelude hiding
( mapM, mapM_, sequence, null, length, foldr
#if MINVER_base_48
-- We hide them, as we import only some members
, Traversable, traverse, sequenceA
, Foldable, foldMap
#if !MINVER_base_48
import Control.Applicative (Applicative (..), (<$), (<$>))
import Distribution.Compat.Semigroup (Monoid (..))
import Data.Foldable (length, null)
import Data.Foldable (Foldable (foldMap, foldr), find, foldl', for_, traverse_)
import Data.Traversable (Traversable (traverse, sequenceA), for)
import Control.Applicative (Alternative (..))
import Control.DeepSeq (NFData (..))
import Data.Data (Data)
import Data.Typeable (Typeable)
import Distribution.Compat.Binary (Binary (..))
import Distribution.Compat.Semigroup (Semigroup (..), gmappend, gmempty)
import GHC.Generics (Generic)
import Data.Map (Map)
import Control.Arrow (first)
import Control.Monad hiding (mapM)
import Data.Char
import Data.List (intercalate, intersperse, isPrefixOf,
isSuffixOf, nub, nubBy, sort, sortBy,
import Data.Maybe
import qualified Text.PrettyPrint as Disp
-- | New name for 'Text.PrettyPrint.<>'
(<<>>) :: Disp.Doc -> Disp.Doc -> Disp.Doc
(<<>>) = (Disp.<>)
#if !MINVER_base_48
-- | Test whether the structure is empty. The default implementation is
-- optimized for structures that are similar to cons-lists, because there
-- is no general way to do better.
null :: Foldable t => t a -> Bool
null = foldr (\_ _ -> False) True
-- | Returns the size/length of a finite structure as an 'Int'. The
-- default implementation is optimized for structures that are similar to
-- cons-lists, because there is no general way to do better.
length :: Foldable t => t a -> Int
length = foldl' (\c _ -> c+1) 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment