diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2013-09-18 10:45:38 +0200 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2013-09-18 10:45:38 +0200 |
commit | 1b608a0d11fda2f3e24751067fb90ca1ba573a3f (patch) | |
tree | 07ba3a0b41ef2b937d219af87734c8bdd0dbf711 | |
parent | 07101847d759592314214c297f68d54f269971dd (diff) | |
download | haskell-1b608a0d11fda2f3e24751067fb90ca1ba573a3f.tar.gz |
Add `{-# MINIMAL #-}` annotations to typeclasses
This makes use of the new `{-# MINIMAL #-}` facility (see #7633)
for the following typeclasses
- `Bits`
- `Foldable`
- `Fractional`
- `Num`
- `MonadZip`
- `Read`
- `Show`
- `Storable`
- `Traversable`
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
-rw-r--r-- | libraries/base/Control/Monad/Zip.hs | 1 | ||||
-rw-r--r-- | libraries/base/Data/Bits.hs | 5 | ||||
-rw-r--r-- | libraries/base/Data/Foldable.hs | 1 | ||||
-rw-r--r-- | libraries/base/Data/Traversable.hs | 1 | ||||
-rw-r--r-- | libraries/base/Foreign/Storable.hs | 4 | ||||
-rw-r--r-- | libraries/base/GHC/Num.lhs | 1 | ||||
-rw-r--r-- | libraries/base/GHC/Read.lhs | 1 | ||||
-rw-r--r-- | libraries/base/GHC/Real.lhs | 1 | ||||
-rw-r--r-- | libraries/base/GHC/Show.lhs | 1 |
9 files changed, 16 insertions, 0 deletions
diff --git a/libraries/base/Control/Monad/Zip.hs b/libraries/base/Control/Monad/Zip.hs index 824e373f73..ec13eedf23 100644 --- a/libraries/base/Control/Monad/Zip.hs +++ b/libraries/base/Control/Monad/Zip.hs @@ -47,6 +47,7 @@ class Monad m => MonadZip m where -- munzip is a member of the class because sometimes -- you can implement it more efficiently than the -- above default code. See Trac #4370 comment by giorgidze + {-# MINIMAL mzip | mzipWith #-} instance MonadZip [] where mzip = zip diff --git a/libraries/base/Data/Bits.hs b/libraries/base/Data/Bits.hs index e2eb3fe0cf..76af67b6f6 100644 --- a/libraries/base/Data/Bits.hs +++ b/libraries/base/Data/Bits.hs @@ -239,6 +239,11 @@ class Eq a => Bits a where known as the population count or the Hamming weight. -} popCount :: a -> Int + {-# MINIMAL (.&.), (.|.), xor, complement, + (shift | (shiftL, shiftR)), + (rotate | (rotateL, rotateR)), + bitSize, bitSizeMaybe, isSigned, testBit, bit, popCount #-} + class Bits b => FiniteBits b where finiteBitSize :: b -> Int diff --git a/libraries/base/Data/Foldable.hs b/libraries/base/Data/Foldable.hs index de6c0562cb..e61972d5a5 100644 --- a/libraries/base/Data/Foldable.hs +++ b/libraries/base/Data/Foldable.hs @@ -151,6 +151,7 @@ class Foldable t where where mf Nothing y = Just y mf (Just x) y = Just (f x y) + {-# MINIMAL foldMap | foldr #-} -- instances for Prelude types diff --git a/libraries/base/Data/Traversable.hs b/libraries/base/Data/Traversable.hs index 7872a617cc..5fa91e8557 100644 --- a/libraries/base/Data/Traversable.hs +++ b/libraries/base/Data/Traversable.hs @@ -164,6 +164,7 @@ class (Functor t, Foldable t) => Traversable t where -- and collect the results. sequence :: Monad m => t (m a) -> m (t a) sequence = mapM id + {-# MINIMAL traverse | sequenceA #-} -- instances for Prelude types diff --git a/libraries/base/Foreign/Storable.hs b/libraries/base/Foreign/Storable.hs index 86e65f8ad7..74417413f2 100644 --- a/libraries/base/Foreign/Storable.hs +++ b/libraries/base/Foreign/Storable.hs @@ -149,6 +149,10 @@ class Storable a where peek ptr = peekElemOff ptr 0 poke ptr = pokeElemOff ptr 0 + {-# MINIMAL sizeOf, alignment, + (peek | peekElemOff | peekByteOff), + (poke | pokeElemOff | pokeByteOff) #-} + -- System-dependent, but rather obvious instances instance Storable Bool where diff --git a/libraries/base/GHC/Num.lhs b/libraries/base/GHC/Num.lhs index 689fafc9a5..7cfc377762 100644 --- a/libraries/base/GHC/Num.lhs +++ b/libraries/base/GHC/Num.lhs @@ -63,6 +63,7 @@ class Num a where {-# INLINE negate #-} x - y = x + negate y negate x = 0 - x + {-# MINIMAL (+), (*), abs, signum, fromInteger, (negate | (-)) #-} -- | the same as @'flip' ('-')@. -- diff --git a/libraries/base/GHC/Read.lhs b/libraries/base/GHC/Read.lhs index 05ee4f90ad..a8494be360 100644 --- a/libraries/base/GHC/Read.lhs +++ b/libraries/base/GHC/Read.lhs @@ -206,6 +206,7 @@ class Read a where readList = readPrec_to_S (list readPrec) 0 readPrec = readS_to_Prec readsPrec readListPrec = readS_to_Prec (\_ -> readList) + {-# MINIMAL readsPrec | readPrec #-} readListDefault :: Read a => ReadS [a] -- ^ A possible replacement definition for the 'readList' method (GHC only). diff --git a/libraries/base/GHC/Real.lhs b/libraries/base/GHC/Real.lhs index 1d5363787e..5cb79de713 100644 --- a/libraries/base/GHC/Real.lhs +++ b/libraries/base/GHC/Real.lhs @@ -192,6 +192,7 @@ class (Num a) => Fractional a where {-# INLINE (/) #-} recip x = 1 / x x / y = x * recip y + {-# MINIMAL fromRational, (recip | (/)) #-} -- | Extracting components of fractions. -- diff --git a/libraries/base/GHC/Show.lhs b/libraries/base/GHC/Show.lhs index 3f31e38615..bce3e73b53 100644 --- a/libraries/base/GHC/Show.lhs +++ b/libraries/base/GHC/Show.lhs @@ -157,6 +157,7 @@ class Show a where showsPrec _ x s = show x ++ s show x = shows x "" showList ls s = showList__ shows ls s + {-# MINIMAL showsPrec | show #-} showList__ :: (a -> ShowS) -> [a] -> ShowS showList__ _ [] s = "[]" ++ s |