summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Enum.hs
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2016-06-04 17:59:47 -0400
committerRyan Scott <ryan.gl.scott@gmail.com>2016-06-04 17:59:48 -0400
commit59651173a52e2400f965e38acd0beb9d0cc14cfe (patch)
treebbcf735fdbf1a7f1975f37b3c5b887a2933016cf /libraries/base/GHC/Enum.hs
parentb948a1da7a3929160cb7cb8d6cf2fe79c3081d0a (diff)
downloadhaskell-59651173a52e2400f965e38acd0beb9d0cc14cfe.tar.gz
Replace hand-written Bounded instances with derived ones
Summary: The spiritual successor to D2291, since deriving `Bounded` instances in `GHC.Enum` wasn't possible prior to changes made in that Diff. This Diff finds every manually implemented `Bounded` instance in `base` that is completely equivalent to the derived instances, and replaces it. Reviewers: bgamari, goldfire, austin, hvr Reviewed By: austin, hvr Subscribers: thomie, rwbarton Differential Revision: https://phabricator.haskell.org/D2301
Diffstat (limited to 'libraries/base/GHC/Enum.hs')
-rw-r--r--libraries/base/GHC/Enum.hs150
1 files changed, 50 insertions, 100 deletions
diff --git a/libraries/base/GHC/Enum.hs b/libraries/base/GHC/Enum.hs
index 729b801dcf..c0e2f5a783 100644
--- a/libraries/base/GHC/Enum.hs
+++ b/libraries/base/GHC/Enum.hs
@@ -1,5 +1,9 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE Trustworthy #-}
-{-# LANGUAGE CPP, NoImplicitPrelude, BangPatterns, MagicHash #-}
{-# OPTIONS_HADDOCK hide #-}
-----------------------------------------------------------------------------
@@ -150,10 +154,7 @@ predError inst_ty =
-- Tuples
------------------------------------------------------------------------
-instance Bounded () where
- minBound = ()
- maxBound = ()
-
+deriving instance Bounded ()
instance Enum () where
succ _ = errorWithoutStackTrace "Prelude.Enum.().succ: bad argument"
pred _ = errorWithoutStackTrace "Prelude.Enum.().pred: bad argument"
@@ -168,102 +169,54 @@ instance Enum () where
enumFromThenTo () () () = let many = ():many in many
-- Report requires instances up to 15
-instance (Bounded a, Bounded b) => Bounded (a,b) where
- minBound = (minBound, minBound)
- maxBound = (maxBound, maxBound)
-
-instance (Bounded a, Bounded b, Bounded c) => Bounded (a,b,c) where
- minBound = (minBound, minBound, minBound)
- maxBound = (maxBound, maxBound, maxBound)
-
-instance (Bounded a, Bounded b, Bounded c, Bounded d) => Bounded (a,b,c,d) where
- minBound = (minBound, minBound, minBound, minBound)
- maxBound = (maxBound, maxBound, maxBound, maxBound)
-
-instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e) => Bounded (a,b,c,d,e) where
- minBound = (minBound, minBound, minBound, minBound, minBound)
- maxBound = (maxBound, maxBound, maxBound, maxBound, maxBound)
-
-instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f)
- => Bounded (a,b,c,d,e,f) where
- minBound = (minBound, minBound, minBound, minBound, minBound, minBound)
- maxBound = (maxBound, maxBound, maxBound, maxBound, maxBound, maxBound)
-
-instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g)
- => Bounded (a,b,c,d,e,f,g) where
- minBound = (minBound, minBound, minBound, minBound, minBound, minBound, minBound)
- maxBound = (maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound)
-
-instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g,
- Bounded h)
- => Bounded (a,b,c,d,e,f,g,h) where
- minBound = (minBound, minBound, minBound, minBound, minBound, minBound, minBound, minBound)
- maxBound = (maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound)
-
-instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g,
- Bounded h, Bounded i)
- => Bounded (a,b,c,d,e,f,g,h,i) where
- minBound = (minBound, minBound, minBound, minBound, minBound, minBound, minBound, minBound,
- minBound)
- maxBound = (maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound,
- maxBound)
-
-instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g,
- Bounded h, Bounded i, Bounded j)
- => Bounded (a,b,c,d,e,f,g,h,i,j) where
- minBound = (minBound, minBound, minBound, minBound, minBound, minBound, minBound, minBound,
- minBound, minBound)
- maxBound = (maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound,
- maxBound, maxBound)
-
-instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g,
- Bounded h, Bounded i, Bounded j, Bounded k)
- => Bounded (a,b,c,d,e,f,g,h,i,j,k) where
- minBound = (minBound, minBound, minBound, minBound, minBound, minBound, minBound, minBound,
- minBound, minBound, minBound)
- maxBound = (maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound,
- maxBound, maxBound, maxBound)
-
-instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g,
- Bounded h, Bounded i, Bounded j, Bounded k, Bounded l)
- => Bounded (a,b,c,d,e,f,g,h,i,j,k,l) where
- minBound = (minBound, minBound, minBound, minBound, minBound, minBound, minBound, minBound,
- minBound, minBound, minBound, minBound)
- maxBound = (maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound,
- maxBound, maxBound, maxBound, maxBound)
-
-instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g,
- Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m)
- => Bounded (a,b,c,d,e,f,g,h,i,j,k,l,m) where
- minBound = (minBound, minBound, minBound, minBound, minBound, minBound, minBound, minBound,
- minBound, minBound, minBound, minBound, minBound)
- maxBound = (maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound,
- maxBound, maxBound, maxBound, maxBound, maxBound)
-
-instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g,
- Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m, Bounded n)
- => Bounded (a,b,c,d,e,f,g,h,i,j,k,l,m,n) where
- minBound = (minBound, minBound, minBound, minBound, minBound, minBound, minBound, minBound,
- minBound, minBound, minBound, minBound, minBound, minBound)
- maxBound = (maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound,
- maxBound, maxBound, maxBound, maxBound, maxBound, maxBound)
-
-instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g,
- Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m, Bounded n, Bounded o)
- => Bounded (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) where
- minBound = (minBound, minBound, minBound, minBound, minBound, minBound, minBound, minBound,
- minBound, minBound, minBound, minBound, minBound, minBound, minBound)
- maxBound = (maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound,
- maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound)
+deriving instance (Bounded a, Bounded b)
+ => Bounded (a,b)
+deriving instance (Bounded a, Bounded b, Bounded c)
+ => Bounded (a,b,c)
+deriving instance (Bounded a, Bounded b, Bounded c, Bounded d)
+ => Bounded (a,b,c,d)
+deriving instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e)
+ => Bounded (a,b,c,d,e)
+deriving instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e,
+ Bounded f)
+ => Bounded (a,b,c,d,e,f)
+deriving instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e,
+ Bounded f, Bounded g)
+ => Bounded (a,b,c,d,e,f,g)
+deriving instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e,
+ Bounded f, Bounded g, Bounded h)
+ => Bounded (a,b,c,d,e,f,g,h)
+deriving instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e,
+ Bounded f, Bounded g, Bounded h, Bounded i)
+ => Bounded (a,b,c,d,e,f,g,h,i)
+deriving instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e,
+ Bounded f, Bounded g, Bounded h, Bounded i, Bounded j)
+ => Bounded (a,b,c,d,e,f,g,h,i,j)
+deriving instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e,
+ Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k)
+ => Bounded (a,b,c,d,e,f,g,h,i,j,k)
+deriving instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e,
+ Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k,
+ Bounded l)
+ => Bounded (a,b,c,d,e,f,g,h,i,j,k,l)
+deriving instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e,
+ Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k,
+ Bounded l, Bounded m)
+ => Bounded (a,b,c,d,e,f,g,h,i,j,k,l,m)
+deriving instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e,
+ Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k,
+ Bounded l, Bounded m, Bounded n)
+ => Bounded (a,b,c,d,e,f,g,h,i,j,k,l,m,n)
+deriving instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e,
+ Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k,
+ Bounded l, Bounded m, Bounded n, Bounded o)
+ => Bounded (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)
------------------------------------------------------------------------
-- Bool
------------------------------------------------------------------------
-instance Bounded Bool where
- minBound = False
- maxBound = True
-
+deriving instance Bounded Bool
instance Enum Bool where
succ False = True
succ True = errorWithoutStackTrace "Prelude.Enum.Bool.succ: bad argument"
@@ -286,10 +239,7 @@ instance Enum Bool where
-- Ordering
------------------------------------------------------------------------
-instance Bounded Ordering where
- minBound = LT
- maxBound = GT
-
+deriving instance Bounded Ordering
instance Enum Ordering where
succ LT = EQ
succ EQ = GT