summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsimonpj <unknown>2005-03-09 17:47:50 +0000
committersimonpj <unknown>2005-03-09 17:47:50 +0000
commit4a93ff07a78a7e7822a029de3696ca0e51d6969c (patch)
tree6759171bc5c94a466c84aa909dc5359dec9df792
parent8a52d9244619afe2a8d33dc916ed54669888f3e2 (diff)
downloadhaskell-4a93ff07a78a7e7822a029de3696ca0e51d6969c.tar.gz
[project @ 2005-03-09 17:47:50 by simonpj]
Add instances for Bounded and Show up to 15-tuples
-rw-r--r--libraries/base/GHC/Enum.lhs78
-rw-r--r--libraries/base/GHC/Show.lhs92
2 files changed, 147 insertions, 23 deletions
diff --git a/libraries/base/GHC/Enum.lhs b/libraries/base/GHC/Enum.lhs
index 89c8b67341..69c49e0ce8 100644
--- a/libraries/base/GHC/Enum.lhs
+++ b/libraries/base/GHC/Enum.lhs
@@ -23,7 +23,6 @@ module GHC.Enum(
) where
-import {-# SOURCE #-} GHC.Err ( error )
import GHC.Base
import Data.Tuple () -- for dependencies
default () -- Double isn't available yet
@@ -147,6 +146,7 @@ instance Enum () where
\end{code}
\begin{code}
+-- Report requires instances up to 15
instance (Bounded a, Bounded b) => Bounded (a,b) where
minBound = (minBound, minBound)
maxBound = (maxBound, maxBound)
@@ -158,6 +158,82 @@ instance (Bounded a, Bounded b, Bounded c) => Bounded (a,b,c) where
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)
\end{code}
diff --git a/libraries/base/GHC/Show.lhs b/libraries/base/GHC/Show.lhs
index f01e29b91c..8673357b88 100644
--- a/libraries/base/GHC/Show.lhs
+++ b/libraries/base/GHC/Show.lhs
@@ -32,14 +32,12 @@ module GHC.Show
)
where
-import {-# SOURCE #-} GHC.Err ( error )
import GHC.Base
-import GHC.Enum
import Data.Maybe
import Data.Either
-import GHC.List ( (!!),
+import GHC.List ( (!!), foldr1
#ifdef USE_REPORT_PRELUDE
- , concatMap, foldr1
+ , concatMap
#endif
)
\end{code}
@@ -229,30 +227,80 @@ instance (Show a, Show b) => Show (Either a b) where
-- \s -> showChar '(' (sx (showChar ',' (sy (showChar ')' s))))
instance (Show a, Show b) => Show (a,b) where
- showsPrec _ (x,y) s = (showChar '(' . shows x . showChar ',' .
- shows y . showChar ')')
- s
+ showsPrec _ (a,b) s = show_tuple [shows a, shows b] s
instance (Show a, Show b, Show c) => Show (a, b, c) where
- showsPrec _ (x,y,z) s = (showChar '(' . shows x . showChar ',' .
- shows y . showChar ',' .
- shows z . showChar ')')
- s
+ showsPrec _ (a,b,c) s = show_tuple [shows a, shows b, shows c] s
instance (Show a, Show b, Show c, Show d) => Show (a, b, c, d) where
- showsPrec _ (w,x,y,z) s = (showChar '(' . shows w . showChar ',' .
- shows x . showChar ',' .
- shows y . showChar ',' .
- shows z . showChar ')')
- s
+ showsPrec _ (a,b,c,d) s = show_tuple [shows a, shows b, shows c, shows d] s
instance (Show a, Show b, Show c, Show d, Show e) => Show (a, b, c, d, e) where
- showsPrec _ (v,w,x,y,z) s = (showChar '(' . shows v . showChar ',' .
- shows w . showChar ',' .
- shows x . showChar ',' .
- shows y . showChar ',' .
- shows z . showChar ')')
- s
+ showsPrec _ (a,b,c,d,e) s = show_tuple [shows a, shows b, shows c, shows d, shows e] s
+
+instance (Show a, Show b, Show c, Show d, Show e, Show f) => Show (a,b,c,d,e,f) where
+ showsPrec _ (a,b,c,d,e,f) s = show_tuple [shows a, shows b, shows c, shows d, shows e, shows f] s
+
+instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g)
+ => Show (a,b,c,d,e,f,g) where
+ showsPrec _ (a,b,c,d,e,f,g) s
+ = show_tuple [shows a, shows b, shows c, shows d, shows e, shows f, shows g] s
+
+instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h)
+ => Show (a,b,c,d,e,f,g,h) where
+ showsPrec _ (a,b,c,d,e,f,g,h) s
+ = show_tuple [shows a, shows b, shows c, shows d, shows e, shows f, shows g, shows h] s
+
+instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i)
+ => Show (a,b,c,d,e,f,g,h,i) where
+ showsPrec _ (a,b,c,d,e,f,g,h,i) s
+ = show_tuple [shows a, shows b, shows c, shows d, shows e, shows f, shows g, shows h,
+ shows i] s
+
+instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j)
+ => Show (a,b,c,d,e,f,g,h,i,j) where
+ showsPrec _ (a,b,c,d,e,f,g,h,i,j) s
+ = show_tuple [shows a, shows b, shows c, shows d, shows e, shows f, shows g, shows h,
+ shows i, shows j] s
+
+instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k)
+ => Show (a,b,c,d,e,f,g,h,i,j,k) where
+ showsPrec _ (a,b,c,d,e,f,g,h,i,j,k) s
+ = show_tuple [shows a, shows b, shows c, shows d, shows e, shows f, shows g, shows h,
+ shows i, shows j, shows k] s
+
+instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k,
+ Show l)
+ => Show (a,b,c,d,e,f,g,h,i,j,k,l) where
+ showsPrec _ (a,b,c,d,e,f,g,h,i,j,k,l) s
+ = show_tuple [shows a, shows b, shows c, shows d, shows e, shows f, shows g, shows h,
+ shows i, shows j, shows k, shows l] s
+
+instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k,
+ Show l, Show m)
+ => Show (a,b,c,d,e,f,g,h,i,j,k,l,m) where
+ showsPrec _ (a,b,c,d,e,f,g,h,i,j,k,l,m) s
+ = show_tuple [shows a, shows b, shows c, shows d, shows e, shows f, shows g, shows h,
+ shows i, shows j, shows k, shows l, shows m] s
+
+instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k,
+ Show l, Show m, Show n)
+ => Show (a,b,c,d,e,f,g,h,i,j,k,l,m,n) where
+ showsPrec _ (a,b,c,d,e,f,g,h,i,j,k,l,m,n) s
+ = show_tuple [shows a, shows b, shows c, shows d, shows e, shows f, shows g, shows h,
+ shows i, shows j, shows k, shows l, shows m, shows n] s
+
+instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k,
+ Show l, Show m, Show n, Show o)
+ => Show (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) where
+ showsPrec _ (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) s
+ = show_tuple [shows a, shows b, shows c, shows d, shows e, shows f, shows g, shows h,
+ shows i, shows j, shows k, shows l, shows m, shows n, shows o] s
+
+show_tuple :: [ShowS] -> ShowS
+show_tuple ss = showChar '('
+ . foldr1 (\s r -> s . showChar ',' . r) ss
+ . showChar ')'
\end{code}