diff --git a/README.markdown b/README.markdown index 593b602..d4468e5 100644 --- a/README.markdown +++ b/README.markdown @@ -1,17 +1,16 @@ # 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 @@ -19,7 +18,7 @@ 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 @@ -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` @@ -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 @@ -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 diff --git a/base-compat.cabal b/base-compat.cabal index bb24775..b15379a 100644 --- a/base-compat.cabal +++ b/base-compat.cabal @@ -27,7 +27,6 @@ library -Wall build-depends: base == 4.* - , ghc-prim , setenv ghc-options: -fno-warn-duplicate-exports @@ -36,12 +35,8 @@ 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 @@ -49,17 +44,13 @@ library 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 diff --git a/check/Data.Traversable.Compat.check.hs b/check/Data.Traversable.Compat.check.hs deleted file mode 100644 index 92da067..0000000 --- a/check/Data.Traversable.Compat.check.hs +++ /dev/null @@ -1,3 +0,0 @@ -{-# LANGUAGE NoImplicitPrelude #-} -module Test where -import Data.Traversable.Compat diff --git a/check/Data.Traversable.Compat.index b/check/Data.Traversable.Compat.index deleted file mode 100644 index d18c602..0000000 --- a/check/Data.Traversable.Compat.index +++ /dev/null @@ -1,10 +0,0 @@ -fmapDefault -foldMapDefault -for -forM -mapAccumL -mapAccumR -mapM -sequence -sequenceA -traverse diff --git a/check/Data.Traversable.Compat.types b/check/Data.Traversable.Compat.types deleted file mode 100644 index 7ab6ab0..0000000 --- a/check/Data.Traversable.Compat.types +++ /dev/null @@ -1,10 +0,0 @@ -fmapDefault :: Traversable t => (a -> b) -> t a -> t b -foldMapDefault :: (Traversable t, GHC.Base.Monoid m) => (a -> m) -> t a -> m -for :: (GHC.Base.Applicative f, Traversable t) => t a -> (a -> f b) -> f (t b) -forM :: (GHC.Base.Monad m, Traversable t) => t a -> (a -> m b) -> m (t b) -mapAccumL :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c) -mapAccumR :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c) -mapM :: (GHC.Base.Monad m, Traversable t) => (a -> m b) -> t a -> m (t b) -sequence :: (GHC.Base.Monad m, Traversable t) => t (m a) -> m (t a) -sequenceA :: (GHC.Base.Applicative f, Traversable t) => t (f a) -> f (t a) -traverse :: (GHC.Base.Applicative f, Traversable t) => (a -> f b) -> t a -> f (t b) diff --git a/mk-index.sh b/mk-index.sh index 69bcc32..27b9243 100755 --- a/mk-index.sh +++ b/mk-index.sh @@ -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 diff --git a/run-check.sh b/run-check.sh index c7a9727..a49a9c4 100755 --- a/run-check.sh +++ b/run-check.sh @@ -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 - diff --git a/src/Control/Applicative/Compat.hs b/src/Control/Applicative/Compat.hs deleted file mode 100644 index ba17070..0000000 --- a/src/Control/Applicative/Compat.hs +++ /dev/null @@ -1,49 +0,0 @@ -{-# LANGUAGE CPP, NoImplicitPrelude #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -module Control.Applicative.Compat ( - module Base -, Applicative(..) -, Alternative(..) -, Const(..) -, WrappedMonad(..) -, WrappedArrow(..) -, ZipList(..) -) where -import Control.Applicative as Base - -#if !MIN_VERSION_base(4,8,0) -import Data.Traversable.Compat () -import GHC.Generics.Compat () -import Prelude.Compat -#endif - -#if !MIN_VERSION_base(4,7,0) --- Added in base-4.7.0.0 -instance Monoid a => Monoid (Const a b) where - mempty = Const mempty - mappend (Const a) (Const b) = Const (mappend a b) - --- Added in base-4.7.0.0 (GHC Trac #8218) -instance Monad m => Monad (WrappedMonad m) where - return = WrapMonad . return - a >>= f = WrapMonad (unwrapMonad a >>= unwrapMonad . f) - -deriving instance Eq a => Eq (ZipList a) -deriving instance Ord a => Ord (ZipList a) -deriving instance Read a => Read (ZipList a) -deriving instance Show a => Show (ZipList a) -#endif - -#if !MIN_VERSION_base(4,8,0) -deriving instance Eq a => Eq (Const a b) -deriving instance Ord a => Ord (Const a b) - -instance Read a => Read (Const a b) where - readsPrec d = readParen (d > 10) - $ \r -> [(Const x,t) | ("Const", s) <- lex r, (x, t) <- readsPrec 11 s] - -instance Show a => Show (Const a b) where - showsPrec d (Const x) = showParen (d > 10) $ - showString "Const " . showsPrec 11 x -#endif diff --git a/src/Control/Concurrent/MVar/Compat.hs b/src/Control/Concurrent/MVar/Compat.hs index 4c8f2b0..aacdfc8 100644 --- a/src/Control/Concurrent/MVar/Compat.hs +++ b/src/Control/Concurrent/MVar/Compat.hs @@ -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 (($)) diff --git a/src/Control/Exception/Compat.hs b/src/Control/Exception/Compat.hs deleted file mode 100644 index 0f93f1b..0000000 --- a/src/Control/Exception/Compat.hs +++ /dev/null @@ -1,15 +0,0 @@ -{-# LANGUAGE CPP, NoImplicitPrelude #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -module Control.Exception.Compat ( - module Base -, ErrorCall(..) -) where - -import Control.Exception as Base - -#if __GLASGOW_HASKELL__ <= 706 -import Prelude.Compat -deriving instance Ord ErrorCall -deriving instance Eq ErrorCall -#endif diff --git a/src/Control/Monad/Compat.hs b/src/Control/Monad/Compat.hs index 6617657..13e1598 100644 --- a/src/Control/Monad/Compat.hs +++ b/src/Control/Monad/Compat.hs @@ -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 @@ -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 @@ -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") diff --git a/src/Data/Bits/Compat.hs b/src/Data/Bits/Compat.hs deleted file mode 100644 index 9d0b0d1..0000000 --- a/src/Data/Bits/Compat.hs +++ /dev/null @@ -1,40 +0,0 @@ -{-# LANGUAGE CPP, NoImplicitPrelude #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -module Data.Bits.Compat ( - module Base -, Bits(..) -) where -import Data.Bits as Base - --- These instances are only valid if Bits isn't a subclass of Num (as Bool is --- not a Num instance), which is only true as of base-4.6.0.0 and later. -#if MIN_VERSION_base(4,6,0) && !MIN_VERSION_base(4,7,0) -import Prelude.Compat - -instance Bits Bool where - (.&.) = (&&) - - (.|.) = (||) - - xor = (/=) - - complement = not - - shift x 0 = x - shift _ _ = False - - rotate x _ = x - - bit 0 = True - bit _ = False - - testBit x 0 = x - testBit _ _ = False - - bitSize _ = 1 - - isSigned _ = False - - popCount False = 0 - popCount True = 1 -#endif diff --git a/src/Data/Bool/Compat.hs b/src/Data/Bool/Compat.hs index 5b12c75..5b5a248 100644 --- a/src/Data/Bool/Compat.hs +++ b/src/Data/Bool/Compat.hs @@ -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@. diff --git a/src/Data/Either/Compat.hs b/src/Data/Either/Compat.hs index 89b210a..f8ac032 100644 --- a/src/Data/Either/Compat.hs +++ b/src/Data/Either/Compat.hs @@ -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. -- diff --git a/src/Data/Foldable/Compat.hs b/src/Data/Foldable/Compat.hs index 390924b..9a17ebb 100644 --- a/src/Data/Foldable/Compat.hs +++ b/src/Data/Foldable/Compat.hs @@ -1,9 +1,7 @@ {-# LANGUAGE CPP, NoImplicitPrelude #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} module Data.Foldable.Compat ( module Base -, Foldable(..) -#if !MIN_VERSION_base(4,8,0) +#if !(MIN_VERSION_base(4,8,0)) , length , null #endif @@ -11,13 +9,7 @@ module Data.Foldable.Compat ( import Data.Foldable as Base -#if !MIN_VERSION_base(4,7,0) -import Data.Either (Either(..)) -import Data.Monoid (mempty) -import Control.Applicative (Const(..)) -#endif - -#if !MIN_VERSION_base(4,8,0) +#if !(MIN_VERSION_base(4,8,0)) import Prelude (Bool(..), Int, (+)) -- | Test whether the structure is empty. The default implementation is @@ -32,20 +24,3 @@ null = foldr (\_ _ -> False) True length :: Foldable t => t a -> Int length = foldl' (\c _ -> c+1) 0 #endif - -#if !MIN_VERSION_base(4,7,0) -instance Foldable (Either a) where - foldMap _ (Left _) = mempty - foldMap f (Right y) = f y - - foldr _ z (Left _) = z - foldr f z (Right y) = f y z - -instance Foldable ((,) a) where - foldMap f (_, y) = f y - - foldr f z (_, y) = f y z - -instance Foldable (Const m) where - foldMap _ _ = mempty -#endif diff --git a/src/Data/Function/Compat.hs b/src/Data/Function/Compat.hs index b1e6250..5382a08 100644 --- a/src/Data/Function/Compat.hs +++ b/src/Data/Function/Compat.hs @@ -5,7 +5,7 @@ module Data.Function.Compat ( ) where import Data.Function as Base -#if !MIN_VERSION_base(4,8,0) +#if !(MIN_VERSION_base(4,8,0)) infixl 1 & -- | '&' is a reverse application operator. This provides notational diff --git a/src/Data/Functor/Compat.hs b/src/Data/Functor/Compat.hs index 484505b..e1e50e1 100644 --- a/src/Data/Functor/Compat.hs +++ b/src/Data/Functor/Compat.hs @@ -7,7 +7,7 @@ module Data.Functor.Compat ( ) where import Data.Functor as Base -#if !MIN_VERSION_base(4,7,0) +#if !(MIN_VERSION_base(4,7,0)) import Control.Monad.Compat (void) import Data.Function (flip) diff --git a/src/Data/List/Compat.hs b/src/Data/List/Compat.hs index 3197e71..5f09c29 100644 --- a/src/Data/List/Compat.hs +++ b/src/Data/List/Compat.hs @@ -2,7 +2,7 @@ {-# LANGUAGE BangPatterns #-} module Data.List.Compat ( module Base -#if !MIN_VERSION_base(4,8,0) +#if !(MIN_VERSION_base(4,8,0)) , all , and , any @@ -34,7 +34,7 @@ module Data.List.Compat ( , scanl' #endif -#if !MIN_VERSION_base(4,5,0) +#if !(MIN_VERSION_base(4,5,0)) , dropWhileEnd #endif ) where @@ -69,12 +69,12 @@ import Data.List as Base hiding ( , mapAccumR ) import Data.Foldable.Compat -import Data.Traversable.Compat +import Data.Traversable import Prelude.Compat hiding (foldr, null) import Data.Ord (comparing) #endif -#if !MIN_VERSION_base(4,5,0) +#if !(MIN_VERSION_base(4,5,0)) -- | The 'dropWhileEnd' function drops the largest suffix of a list -- in which the given predicate holds for all elements. For example: -- @@ -88,7 +88,7 @@ dropWhileEnd p = foldr (\x xs -> if p x && null xs then [] else x : xs) [] #endif -#if !MIN_VERSION_base(4,8,0) +#if !(MIN_VERSION_base(4,8,0)) -- | The 'isSubsequenceOf' function takes two lists and returns 'True' if the -- first list is a subsequence of the second list. -- diff --git a/src/Data/Monoid/Compat.hs b/src/Data/Monoid/Compat.hs index 4b0dd98..8d4ab03 100644 --- a/src/Data/Monoid/Compat.hs +++ b/src/Data/Monoid/Compat.hs @@ -1,51 +1,13 @@ {-# LANGUAGE CPP, NoImplicitPrelude #-} -{-# LANGUAGE GeneralizedNewtypeDeriving, StandaloneDeriving #-} - -#if __GLASGOW_HASKELL__ >= 702 -{-# LANGUAGE DeriveGeneric #-} -#endif - -#if __GLASGOW_HASKELL__ >= 706 -{-# LANGUAGE PolyKinds #-} -#endif - -{-# OPTIONS_GHC -fno-warn-orphans #-} module Data.Monoid.Compat ( - -- * Monoid typeclass - Monoid(..), - (<>), - Dual(..), - Endo(..), - -- * Bool wrappers - All(..), - Any(..), - -- * Num wrappers - Sum(..), - Product(..), - -- * Maybe wrappers - -- $MaybeExamples - First(..), - Last(..), - -- * Alternative wrapper - Alt(..) - ) where + module Base +, (<>) +) where import Data.Monoid as Base --- To import orphan Generic instances for Sum and Product -import GHC.Generics.Compat () - -#if !MIN_VERSION_base(4,8,0) -import Control.Applicative -import Control.Monad -import Prelude.Compat - -# if __GLASGOW_HASKELL__ >= 702 -import GHC.Generics -# endif -#endif +#if !(MIN_VERSION_base(4,5,0)) -#if !MIN_VERSION_base(4,5,0) infixr 6 <> -- | An infix synonym for 'mappend'. @@ -54,36 +16,5 @@ infixr 6 <> (<>) :: Monoid m => m -> m -> m (<>) = mappend {-# INLINE (<>) #-} -#endif - -#if !MIN_VERSION_base(4,7,0) -deriving instance Num a => Num (Sum a) -deriving instance Num a => Num (Product a) -#endif - -#if !MIN_VERSION_base(4,8,0) --- | Monoid under '<|>'. --- --- /Since: 4.8.0.0/ -newtype Alt f a = Alt {getAlt :: f a} - deriving ( Read, Show, Eq, Ord, Num, Enum -# if __GLASGOW_HASKELL__ >= 702 - , Generic -# endif -# if __GLASGOW_HASKELL__ >= 708 - , Generic1 -# endif - ) - --- To work around a GHC 7.6 bug, we'll use StandaloneDeriving for generalized --- derivations that involve higher-kinded typeclasses. -deriving instance Functor f => Functor (Alt f) -deriving instance Applicative f => Applicative (Alt f) -deriving instance Monad m => Monad (Alt m) -deriving instance Alternative f => Alternative (Alt f) -deriving instance MonadPlus m => MonadPlus (Alt m) -instance Alternative f => Monoid (Alt f a) where - mempty = Alt empty - mappend (Alt x) (Alt y) = Alt (x <|> y) #endif diff --git a/src/Data/Ord/Compat.hs b/src/Data/Ord/Compat.hs deleted file mode 100644 index 5aa27b8..0000000 --- a/src/Data/Ord/Compat.hs +++ /dev/null @@ -1,23 +0,0 @@ -{-# LANGUAGE CPP, NoImplicitPrelude #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -module Data.Ord.Compat ( - module Base -, Ord(..) -, Down(..) -) where -import Data.Ord as Base - -#if !MIN_VERSION_base(4,7,0) -import Prelude.Compat -#endif - -#if MIN_VERSION_base(4,6,0) && !MIN_VERSION_base(4,7,0) -deriving instance Read a => Read (Down a) -deriving instance Show a => Show (Down a) -#elif !MIN_VERSION_base(4,6,0) -newtype Down a = Down a deriving (Eq, Show, Read) - -instance Ord a => Ord (Down a) where - compare (Down x) (Down y) = y `compare` x -#endif diff --git a/src/Data/Traversable/Compat.hs b/src/Data/Traversable/Compat.hs deleted file mode 100644 index 171b665..0000000 --- a/src/Data/Traversable/Compat.hs +++ /dev/null @@ -1,24 +0,0 @@ -{-# LANGUAGE CPP, NoImplicitPrelude #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -module Data.Traversable.Compat ( - module Base -, Traversable(..) -) where -import Data.Traversable as Base - -#if !MIN_VERSION_base(4,7,0) -import Data.Either (Either(..)) -import Data.Foldable.Compat () -import Data.Function (($)) -import Control.Applicative (Const(..),pure,(<$>)) - -instance Traversable (Either a) where - traverse _ (Left x) = pure (Left x) - traverse f (Right y) = Right <$> f y - -instance Traversable ((,) a) where - traverse f (x, y) = (,) x <$> f y - -instance Traversable (Const m) where - traverse _ (Const m) = pure $ Const m -#endif diff --git a/src/Data/Version/Compat.hs b/src/Data/Version/Compat.hs index 71b656e..539e9cb 100644 --- a/src/Data/Version/Compat.hs +++ b/src/Data/Version/Compat.hs @@ -1,42 +1,16 @@ {-# LANGUAGE CPP, NoImplicitPrelude #-} -{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving, TypeFamilies #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} module Data.Version.Compat ( module Base -, Version(..) , makeVersion ) where import Data.Version as Base -#if !MIN_VERSION_base(4,7,0) -import Data.Data -#endif - -#if !MIN_VERSION_base(4,8,0) +#if !(MIN_VERSION_base(4,8,0)) import Prelude.Compat -# if MIN_VERSION_base(4,7,0) -import GHC.Exts (IsList(..)) -# endif -#endif - -#if !MIN_VERSION_base(4,7,0) -deriving instance Data Version -#endif - -#if !MIN_VERSION_base(4,8,0) -- | Construct tag-less 'Version' -- -- /Since: 4.8.0.0/ makeVersion :: [Int] -> Version makeVersion b = Version b [] - -# if MIN_VERSION_base(4,7,0) --- | /Since: 4.8.0.0/ -instance IsList Version where - type (Item Version) = Int - fromList = makeVersion - toList = versionBranch -# endif - #endif diff --git a/src/Debug/Trace/Compat.hs b/src/Debug/Trace/Compat.hs index f28f28b..522659a 100644 --- a/src/Debug/Trace/Compat.hs +++ b/src/Debug/Trace/Compat.hs @@ -8,7 +8,7 @@ module Debug.Trace.Compat ( ) where import Debug.Trace as Base -#if !MIN_VERSION_base(4,7,0) +#if !(MIN_VERSION_base(4,7,0)) import Prelude.Compat {-| diff --git a/src/Foreign/Compat.hs b/src/Foreign/Compat.hs index f7597af..856dacc 100644 --- a/src/Foreign/Compat.hs +++ b/src/Foreign/Compat.hs @@ -1,12 +1,8 @@ -{-# LANGUAGE CPP, NoImplicitPrelude #-} +{-# LANGUAGE NoImplicitPrelude #-} module Foreign.Compat ( module Base -, module Bits -, module Storable , module Marshal ) where import Foreign as Base -import Data.Bits.Compat as Bits import Foreign.Marshal.Compat as Marshal -import Foreign.Storable.Compat as Storable diff --git a/src/Foreign/Marshal/Alloc/Compat.hs b/src/Foreign/Marshal/Alloc/Compat.hs index 3e63869..edc0dbf 100644 --- a/src/Foreign/Marshal/Alloc/Compat.hs +++ b/src/Foreign/Marshal/Alloc/Compat.hs @@ -7,10 +7,10 @@ module Foreign.Marshal.Alloc.Compat ( ) where import Foreign.Marshal.Alloc as Base -#if !MIN_VERSION_base(4,8,0) +#if !(MIN_VERSION_base(4,8,0)) import Foreign.C.Types import Foreign.Ptr (Ptr, nullPtr) -import Foreign.Storable.Compat (Storable(..)) +import Foreign.Storable (Storable(..)) import GHC.IO.Exception import Prelude.Compat diff --git a/src/Foreign/Marshal/Array/Compat.hs b/src/Foreign/Marshal/Array/Compat.hs index 169e942..79b160a 100644 --- a/src/Foreign/Marshal/Array/Compat.hs +++ b/src/Foreign/Marshal/Array/Compat.hs @@ -6,10 +6,10 @@ module Foreign.Marshal.Array.Compat ( ) where import Foreign.Marshal.Array as Base -#if !MIN_VERSION_base(4,8,0) +#if !(MIN_VERSION_base(4,8,0)) import Foreign.Marshal.Alloc.Compat import Foreign.Ptr (Ptr) -import Foreign.Storable.Compat (Storable(..)) +import Foreign.Storable (Storable(..)) import Prelude.Compat -- |Like 'mallocArray', but allocated memory is filled with bytes of value zero. diff --git a/src/Foreign/Storable/Compat.hs b/src/Foreign/Storable/Compat.hs deleted file mode 100644 index 0e1d59d..0000000 --- a/src/Foreign/Storable/Compat.hs +++ /dev/null @@ -1,43 +0,0 @@ -{-# LANGUAGE CPP, NoImplicitPrelude #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -module Foreign.Storable.Compat ( - module Base -, Storable(..) -) where -import Foreign.Storable as Base - -#if !MIN_VERSION_base(4,8,0) -import Data.Complex (Complex(..), realPart) -import Foreign.Ptr (castPtr) -import GHC.Real (Ratio(..), (%)) -import Prelude.Compat - --- The actual constraint in base-4.8.0.0 doesn't include RealFloat a, but it --- is needed in previous versions of base due to Complex having lots of --- RealFloat constraints in its functions' type signatures. -instance (Storable a, RealFloat a) => Storable (Complex a) where - sizeOf a = 2 * sizeOf (realPart a) - alignment a = alignment (realPart a) - peek p = do - q <- return $ castPtr p - r <- peek q - i <- peekElemOff q 1 - return (r :+ i) - poke p (r :+ i) = do - q <-return $ (castPtr p) - poke q r - pokeElemOff q 1 i - -instance (Storable a, Integral a) => Storable (Ratio a) where - sizeOf (n :% _) = 2 * sizeOf n - alignment (n :% _) = alignment n - peek p = do - q <- return $ castPtr p - r <- peek q - i <- peekElemOff q 1 - return (r % i) - poke p (r :% i) = do - q <-return $ (castPtr p) - poke q r - pokeElemOff q 1 i -#endif diff --git a/src/GHC/Generics/Compat.hs b/src/GHC/Generics/Compat.hs deleted file mode 100644 index 74660bd..0000000 --- a/src/GHC/Generics/Compat.hs +++ /dev/null @@ -1,132 +0,0 @@ -{-# LANGUAGE CPP, NoImplicitPrelude #-} -{-# LANGUAGE FlexibleContexts, StandaloneDeriving, TypeOperators #-} - -#if __GLASGOW_HASKELL__ >= 702 -{-# LANGUAGE DeriveGeneric #-} -#endif -{-# OPTIONS_GHC -fno-warn-orphans #-} -module GHC.Generics.Compat ( --- GHC.Generics is only available on GHC 7.2 and later, so we can't export anything --- if we're using a GHC prior to 7.2 -#if __GLASGOW_HASKELL__ < 702 -) where -#else - module Base - -- * Generic representation types -, U1(..) -, Par1(..) -, Rec1(..) -, K1(..) -, M1(..) -, (:+:)(..) -, (:*:)(..) -, (:.:)(..) - -- * Generic type classes -, Generic(..) -, Generic1(..) -) where -import GHC.Generics as Base - -# if !MIN_VERSION_base(4,7,0) -import GHC.Read -import Prelude.Compat -import qualified Text.ParserCombinators.ReadPrec as ReadPrec -import Text.Read.Lex - --- Although DeriveGeneric has been around since GHC 7.2, various bugs cause --- the standalone-derived code below to fail to compile unless a fairly --- recent version of GHC is used. -# if __GLASGOW_HASKELL__ >= 706 -import Control.Applicative -import Data.Monoid - -deriving instance Generic All -deriving instance Generic Any -deriving instance Generic (Const a b) -deriving instance Generic (Dual a) -deriving instance Generic (Endo a) -deriving instance Generic (First a) -deriving instance Generic (Last a) -deriving instance Generic (Product a) -deriving instance Generic (Sum a) -deriving instance Generic (WrappedArrow a b c) -deriving instance Generic (WrappedMonad m a) -deriving instance Generic (ZipList a) - -deriving instance Generic1 (Const a) -deriving instance Generic1 Dual -deriving instance Generic1 First -deriving instance Generic1 Last -deriving instance Generic1 Product -deriving instance Generic1 Sum -deriving instance Generic1 (WrappedArrow a b) -deriving instance Generic1 (WrappedMonad m) -deriving instance Generic1 ZipList - -deriving instance Generic (U1 p) -deriving instance Generic (Par1 p) -deriving instance Generic (Rec1 f p) -deriving instance Generic (K1 i c p) -deriving instance Generic (M1 i c f p) -deriving instance Generic ((f :+: g) p) -deriving instance Generic ((f :*: g) p) -deriving instance Generic ((f :.: g) p) -# endif - -deriving instance Eq (U1 p) -deriving instance Ord (U1 p) -deriving instance Read (U1 p) -deriving instance Show (U1 p) - -deriving instance Eq p => Eq (Par1 p) -deriving instance Ord p => Ord (Par1 p) -deriving instance Read p => Read (Par1 p) -deriving instance Show p => Show (Par1 p) - -deriving instance Eq (f p) => Eq (Rec1 f p) -deriving instance Ord (f p) => Ord (Rec1 f p) -deriving instance Read (f p) => Read (Rec1 f p) -deriving instance Show (f p) => Show (Rec1 f p) - -deriving instance Eq c => Eq (K1 i c p) -deriving instance Ord c => Ord (K1 i c p) -deriving instance Read c => Read (K1 i c p) -deriving instance Show c => Show (K1 i c p) - -deriving instance Eq (f p) => Eq (M1 i c f p) -deriving instance Ord (f p) => Ord (M1 i c f p) -deriving instance Read (f p) => Read (M1 i c f p) -deriving instance Show (f p) => Show (M1 i c f p) - -deriving instance (Eq (f p), Eq (g p)) => Eq ((f :+: g) p) -deriving instance (Ord (f p), Ord (g p)) => Ord ((f :+: g) p) -deriving instance (Read (f p), Read (g p)) => Read ((f :+: g) p) -deriving instance (Show (f p), Show (g p)) => Show ((f :+: g) p) - -deriving instance (Eq (f p), Eq (g p)) => Eq ((f :*: g) p) -deriving instance (Ord (f p), Ord (g p)) => Ord ((f :*: g) p) --- Due to a GHC bug (https://ghc.haskell.org/trac/ghc/ticket/9830), the derived --- Read and Show instances for infix data constructors will use the wrong --- precedence (prior to GHC 7.10). --- We'll manually derive Read :*: and Show :*: instances to avoid this. -instance (Read (f p), Read (g p)) => Read ((f :*: g) p) where - readPrec = parens . ReadPrec.prec 6 $ do - fp <- ReadPrec.step readPrec - Symbol ":*:" <- lexP - gp <- ReadPrec.step readPrec - return $ fp :*: gp - readListPrec = readListPrecDefault -instance (Show (f p), Show (g p)) => Show ((f :*: g) p) where - showsPrec p (l :*: r) = showParen (p > sixPrec) $ - showsPrec (sixPrec + 1) l - . showString " :*: " - . showsPrec (sixPrec + 1) r - where sixPrec = 6 - -deriving instance Eq (f (g p)) => Eq ((f :.: g) p) -deriving instance Ord (f (g p)) => Ord ((f :.: g) p) -deriving instance Read (f (g p)) => Read ((f :.: g) p) -deriving instance Show (f (g p)) => Show ((f :.: g) p) -# endif - -#endif diff --git a/src/Prelude/Compat.hs b/src/Prelude/Compat.hs index dc6b1da..fb14619 100644 --- a/src/Prelude/Compat.hs +++ b/src/Prelude/Compat.hs @@ -292,7 +292,7 @@ import Prelude hiding ( import Data.Word import Data.Foldable.Compat -import Data.Traversable.Compat +import Data.Traversable import Data.Monoid import Control.Applicative #endif diff --git a/src/System/Console/GetOpt/Compat.hs b/src/System/Console/GetOpt/Compat.hs deleted file mode 100644 index 309fea6..0000000 --- a/src/System/Console/GetOpt/Compat.hs +++ /dev/null @@ -1,27 +0,0 @@ -{-# LANGUAGE CPP, NoImplicitPrelude #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -module System.Console.GetOpt.Compat ( - module Base -, ArgOrder(..) -, OptDescr(..) -, ArgDescr(..) -) where -import System.Console.GetOpt as Base - -#if !MIN_VERSION_base(4,7,0) -import Data.Function ((.)) -import Data.Functor (Functor(..)) - -instance Functor ArgOrder where - fmap _ RequireOrder = RequireOrder - fmap _ Permute = Permute - fmap f (ReturnInOrder g) = ReturnInOrder (f . g) - -instance Functor OptDescr where - fmap f (Option a b argDescr c) = Option a b (fmap f argDescr) c - -instance Functor ArgDescr where - fmap f (NoArg a) = NoArg (f a) - fmap f (ReqArg g s) = ReqArg (f . g) s - fmap f (OptArg g s) = OptArg (f . g) s -#endif diff --git a/src/System/Environment/Compat.hs b/src/System/Environment/Compat.hs index dd74db9..a86adae 100644 --- a/src/System/Environment/Compat.hs +++ b/src/System/Environment/Compat.hs @@ -14,11 +14,11 @@ module System.Environment.Compat ( import System.Environment -#if !MIN_VERSION_base(4,7,0) +#if !(MIN_VERSION_base(4,7,0)) import System.SetEnv #endif -#if !MIN_VERSION_base(4,6,0) +#if !(MIN_VERSION_base(4,6,0)) import Prelude.Compat -- | Return the value of the environment variable @var@, or @Nothing@ if -- there is no such value. diff --git a/src/System/Exit/Compat.hs b/src/System/Exit/Compat.hs index ef36ab1..75df19d 100644 --- a/src/System/Exit/Compat.hs +++ b/src/System/Exit/Compat.hs @@ -1,16 +1,13 @@ {-# LANGUAGE CPP, NoImplicitPrelude #-} {-# LANGUAGE CPP #-} module System.Exit.Compat ( - ExitCode(..) -, exitWith -, exitFailure -, exitSuccess + module Base , die ) where -import System.Exit +import System.Exit as Base -#if !MIN_VERSION_base(4,8,0) +#if !(MIN_VERSION_base(4,8,0)) import Prelude.Compat import System.IO diff --git a/src/Text/Read/Compat.hs b/src/Text/Read/Compat.hs index af6fec6..880a6a0 100644 --- a/src/Text/Read/Compat.hs +++ b/src/Text/Read/Compat.hs @@ -26,7 +26,7 @@ import Text.Read import Text.ParserCombinators.ReadPrec import qualified Text.Read.Lex as L -#if !MIN_VERSION_base(4,6,0) +#if !(MIN_VERSION_base(4,6,0)) import Prelude.Compat import qualified Text.ParserCombinators.ReadP as P diff --git a/test/Control/Applicative/CompatSpec.hs b/test/Control/Applicative/CompatSpec.hs deleted file mode 100644 index 767a7ce..0000000 --- a/test/Control/Applicative/CompatSpec.hs +++ /dev/null @@ -1,38 +0,0 @@ -{-# LANGUAGE DeriveFunctor #-} -module Control.Applicative.CompatSpec (main, spec) where - -import Test.Hspec - -import Control.Applicative.Compat -import Data.Monoid.Compat - --- simplest one to use -newtype Identity a = Identity { runIdentity :: a } - deriving Functor - -instance Applicative Identity where - pure = Identity - Identity f <*> x = f <$> x - -instance Monad Identity where - return = Identity - m >>= k = k (runIdentity m) - -main :: IO () -main = hspec spec - -spec :: Spec -spec = do - describe "Monoid (Const a b)" $ do - it "mempty returns an empty const" $ - getConst (mempty :: (Const String Int)) `shouldBe` "" - it "mappends const part" $ - getConst ((Const "aaa" :: Const String Int) <> (Const "bbb" :: Const String Int)) - `shouldBe` "aaabbb" - - describe "Monad (WrappedMonad m)" $ - it "allows to use a Monad interface in a WrappedMonad" $ - (runIdentity . unwrapMonad - $ (WrapMonad (return 1 :: Identity Int)) - >> (WrapMonad (return 2 :: Identity Int))) - `shouldBe` (2::Int) diff --git a/test/Control/Exception/CompatSpec.hs b/test/Control/Exception/CompatSpec.hs deleted file mode 100644 index 5dc1a76..0000000 --- a/test/Control/Exception/CompatSpec.hs +++ /dev/null @@ -1,17 +0,0 @@ -module Control.Exception.CompatSpec (main, spec) where - -import Test.Hspec - -import Control.Exception.Compat - -main :: IO () -main = hspec spec - -spec :: Spec -spec = do - describe "ErrorCall" $ do - it "has an Eq instance" $ do - ErrorCall "foo" `shouldBe` ErrorCall "foo" - - it "has an Ord instance" $ do - ErrorCall "foo" `shouldSatisfy` (> ErrorCall "bar") diff --git a/test/Data/Bits/CompatSpec.hs b/test/Data/Bits/CompatSpec.hs deleted file mode 100644 index 25f7912..0000000 --- a/test/Data/Bits/CompatSpec.hs +++ /dev/null @@ -1,24 +0,0 @@ -{-# LANGUAGE CPP #-} -module Data.Bits.CompatSpec (main, spec) where - -import Test.Hspec - -#if MIN_VERSION_base(4,6,0) -import Data.Bits.Compat -#endif - -main :: IO () -main = hspec spec - -spec :: Spec -spec = -#if MIN_VERSION_base(4,6,0) - describe "Bits Bool instance" $ - it "allows bitwise operations on Bools" $ do - True .&. True `shouldBe` True - True .&. False `shouldBe` False - False .&. True `shouldBe` False - False .&. False `shouldBe` False -#else - return () -#endif diff --git a/test/Data/Foldable/CompatSpec.hs b/test/Data/Foldable/CompatSpec.hs deleted file mode 100644 index 8fce509..0000000 --- a/test/Data/Foldable/CompatSpec.hs +++ /dev/null @@ -1,39 +0,0 @@ -module Data.Foldable.CompatSpec (main, spec) where - -import Test.Hspec - -import Data.Foldable.Compat as F -import Data.Monoid.Compat -import Control.Applicative.Compat (Const(..)) - -main :: IO () -main = hspec spec - -spec :: Spec -spec = do - describe "Either Foldable Instance" $ do - it "foldMap returns mempty for a Left value" $ - foldMap (<> "+") (Left "abc" :: Either String String) `shouldBe` mempty - it "foldMap returns the result of the function on the Right value" $ - foldMap (<> "+") (Right "abc" :: Either String String) `shouldBe` "abc+" - - it "foldr returns the accumulator for a Left value" $ - F.foldr (<>) "+" (Left "abc" :: Either String String) `shouldBe` "+" - it "foldr returns the result of the function on the Right value and accumulator" $ - F.foldr (<>) "+" (Right "abc" :: Either String String) `shouldBe` "abc+" - - describe "(,) Foldable Instance" $ do - it "foldMap returns the result of the function applied to the second element" $ - foldMap (<> "+") ("xyz","abc") `shouldBe` "abc+" - - it "foldr returns the result of the function on the second element of the tuple and accumulator" $ - F.foldr (<>) "+" ("xyz","abc") `shouldBe` "abc+" - - describe "Const m Foldable Instance" $ do - it "foldMap always returns mempty" $ - foldMap (<> "+") (Const "abc") `shouldBe` "" - it "foldr applies the function to the accumulator and mempty" $ do - F.foldr (<>) "+" (Const "abc") `shouldBe` "+" - - - diff --git a/test/Data/Monoid/CompatSpec.hs b/test/Data/Monoid/CompatSpec.hs index 3484b46..bf3ec28 100644 --- a/test/Data/Monoid/CompatSpec.hs +++ b/test/Data/Monoid/CompatSpec.hs @@ -3,7 +3,6 @@ module Data.Monoid.CompatSpec (main, spec) where import Test.Hspec import Test.QuickCheck -import Control.Applicative import Data.Monoid.Compat main :: IO () @@ -15,15 +14,3 @@ spec = do it "is an infix synonym for mappend" $ do property $ \xs ys -> do xs <> ys `shouldBe` (mappend xs ys :: String) - describe "Num (Sum a) instance" $ - it "allows a Sum value to be created from a number" $ - 1 `shouldBe` Sum (1 :: Int) - describe "Num (Product a) instance" $ - it "allows a Product value to be created from a number" $ - 1 `shouldBe` Product (1 :: Int) - describe "Monoid (Alt f a) instance" $ - it "admits a Monoid from an Alternative instance" $ - property $ \x y z -> do - Alt x <> Alt (empty :: String) `shouldBe` Alt x - Alt (empty :: String) <> Alt x `shouldBe` Alt x - Alt x <> (Alt y <> Alt z) `shouldBe` (Alt x <> Alt y) <> Alt z diff --git a/test/Data/Ord/CompatSpec.hs b/test/Data/Ord/CompatSpec.hs deleted file mode 100644 index f2e7dd4..0000000 --- a/test/Data/Ord/CompatSpec.hs +++ /dev/null @@ -1,13 +0,0 @@ -module Data.Ord.CompatSpec (main, spec) where - -import Test.Hspec -import Data.Ord.Compat - -main :: IO () -main = hspec spec - -spec :: Spec -spec = do - describe "Ord (Down a) instance" $ - it "reverses the order in which two values are compared" $ - Down 'a' < Down 'b' `shouldBe` False diff --git a/test/Data/Traversable/CompatSpec.hs b/test/Data/Traversable/CompatSpec.hs deleted file mode 100644 index 1c7e9e5..0000000 --- a/test/Data/Traversable/CompatSpec.hs +++ /dev/null @@ -1,27 +0,0 @@ -{-# LANGUAGE TupleSections, NoImplicitPrelude #-} -module Data.Traversable.CompatSpec (main, spec) where - -import Prelude.Compat -import Test.Hspec - -import Control.Applicative.Compat (Const(..)) - -main :: IO () -main = hspec spec - -spec :: Spec -spec = do - describe "Either Traversable Instance" $ do - it "traverses a Left value" $ - traverse (:[]) (Left 5 :: Either Int String) `shouldBe` [Left 5] - it "traverses a Right Value" $ - traverse (:[]) (Right "aaa" :: Either Int String) `shouldBe` [Right "aaa"] - - describe "(,) a Traversable Instance" $ do - it "traverses a (,) a value" $ - traverse (:[]) (5::Int,"aaa") `shouldBe` [(5,"aaa")] - - describe "Const m Traversable Instance" $ do - it "traverses a Const a value" $ do - fmap getConst (traverse (:[]) (Const 5 :: Const Int String)) `shouldBe` [5] - diff --git a/test/Data/Version/CompatSpec.hs b/test/Data/Version/CompatSpec.hs index 761efd8..13f014c 100644 --- a/test/Data/Version/CompatSpec.hs +++ b/test/Data/Version/CompatSpec.hs @@ -1,28 +1,10 @@ -{-# LANGUAGE CPP #-} -#if MIN_VERSION_base(4,7,0) -{-# LANGUAGE OverloadedLists #-} -#endif -module Data.Version.CompatSpec (main, spec) where +module Data.Version.CompatSpec (spec) where import Test.Hspec -import Data.Data import Data.Version.Compat -main :: IO () -main = hspec spec - spec :: Spec spec = do describe "makeVersion" $ it "constructs a tagless Version" $ makeVersion [1,2,3] `shouldBe` Version [1,2,3] [] - - describe "Data Version instance" $ - it "allows obtaining a Version constructor" $ - dataTypeName (dataTypeOf (makeVersion [1,2,3])) `shouldBe` "Data.Version.Version" - -#if MIN_VERSION_base(4,7,0) - describe "IsList Version instance" $ - it "creates a Version from an Int list" $ - [1,2,3] `shouldBe` makeVersion [1,2,3] -#endif diff --git a/test/Foreign/Marshal/Alloc/CompatSpec.hs b/test/Foreign/Marshal/Alloc/CompatSpec.hs index 02dfa03..c873d03 100644 --- a/test/Foreign/Marshal/Alloc/CompatSpec.hs +++ b/test/Foreign/Marshal/Alloc/CompatSpec.hs @@ -2,9 +2,9 @@ module Foreign.Marshal.Alloc.CompatSpec (main, spec) where import Test.Hspec -import Control.Exception.Compat +import Control.Exception import Foreign.Marshal.Alloc.Compat -import Foreign.Storable.Compat +import Foreign.Storable main :: IO () main = hspec spec diff --git a/test/Foreign/Storable/CompatSpec.hs b/test/Foreign/Storable/CompatSpec.hs deleted file mode 100644 index bd0341f..0000000 --- a/test/Foreign/Storable/CompatSpec.hs +++ /dev/null @@ -1,23 +0,0 @@ -module Foreign.Storable.CompatSpec (main, spec) where - -import Test.Hspec -import Data.Complex -import Data.Ratio -import Foreign.Storable.Compat - -main :: IO () -main = hspec spec - -spec :: Spec -spec = do - describe "Storable Complex instance" $ do - it "has twice the sizeOf its realPart" $ do - sizeOf ((1 :: Double) :+ 2) `shouldBe` 2*sizeOf (1 :: Double) - it "has the alignment of its realPart" $ do - alignment ((1 :: Double) :+ 2) `shouldBe` alignment (1 :: Double) - - describe "Storable Ratio instance" $ do - it "has twice the sizeOf its parameterized type" $ do - sizeOf ((1 :: Int) % 2) `shouldBe` 2*sizeOf (1 :: Int) - it "has the alignment of its parameterized type" $ do - alignment ((1 :: Int) % 2) `shouldBe` alignment (1 :: Int)