summaryrefslogtreecommitdiff
path: root/libraries/base/Data
diff options
context:
space:
mode:
authorsimonmar <unknown>2001-12-21 15:07:26 +0000
committersimonmar <unknown>2001-12-21 15:07:26 +0000
commitceb68b9118fa883e88abfaa532fc78f6640cf17f (patch)
treeb90b04a394fee4abd0cb09205120bee964684d7b /libraries/base/Data
parentb83cfb91b4d36d148ebe171d31e2676c8f10f371 (diff)
downloadhaskell-ceb68b9118fa883e88abfaa532fc78f6640cf17f.tar.gz
[project @ 2001-12-21 15:07:20 by simonmar]
Merge up to the ghc/lib/std on the HEAD (tagged as new-libraries-last-merged).
Diffstat (limited to 'libraries/base/Data')
-rw-r--r--libraries/base/Data/Bits.hs17
-rw-r--r--libraries/base/Data/Complex.hs8
-rw-r--r--libraries/base/Data/Dynamic.hs4
-rw-r--r--libraries/base/Data/IORef.hs4
-rw-r--r--libraries/base/Data/Ix.hs4
-rw-r--r--libraries/base/Data/List.hs24
-rw-r--r--libraries/base/Data/Tuple.hs24
7 files changed, 45 insertions, 40 deletions
diff --git a/libraries/base/Data/Bits.hs b/libraries/base/Data/Bits.hs
index 9b6861869c..8303545be1 100644
--- a/libraries/base/Data/Bits.hs
+++ b/libraries/base/Data/Bits.hs
@@ -9,7 +9,7 @@
-- Stability : experimental
-- Portability : portable
--
--- $Id: Bits.hs,v 1.2 2001/07/03 11:37:49 simonmar Exp $
+-- $Id: Bits.hs,v 1.3 2001/12/21 15:07:21 simonmar Exp $
--
-- Bitwise operations.
--
@@ -92,20 +92,13 @@ instance Bits Int where
| i# >=# 0# = I# (x# `iShiftL#` i#)
| otherwise = I# (x# `iShiftRA#` negateInt# i#)
(I# x#) `rotate` (I# i#) =
-#if WORD_SIZE_IN_BYTES == 4
I# (word2Int# ((x'# `shiftL#` i'#) `or#`
- (x'# `shiftRL#` (32# -# i'#))))
+ (x'# `shiftRL#` (wsib -# i'#))))
where
x'# = int2Word# x#
- i'# = word2Int# (int2Word# i# `and#` int2Word# 31#)
-#else
- I# (word2Int# ((x'# `shiftL#` i'#) `or#`
- (x'# `shiftRL#` (64# -# i'#))))
- where
- x'# = int2Word# x#
- i'# = word2Int# (int2Word# i# `and#` int2Word# 63#)
-#endif
- bitSize _ = WORD_SIZE_IN_BYTES * 8
+ i'# = word2Int# (int2Word# i# `and#` int2Word# (wsib -# 1#))
+ wsib = WORD_SIZE_IN_BITS# {- work around preprocessor problem (??) -}
+ bitSize _ = WORD_SIZE_IN_BITS
isSigned _ = True
instance Bits Integer where
diff --git a/libraries/base/Data/Complex.hs b/libraries/base/Data/Complex.hs
index e132f2186c..8482e500c8 100644
--- a/libraries/base/Data/Complex.hs
+++ b/libraries/base/Data/Complex.hs
@@ -8,7 +8,7 @@
-- Stability : provisional
-- Portability : portable
--
--- $Id: Complex.hs,v 1.1 2001/06/28 14:15:02 simonmar Exp $
+-- $Id: Complex.hs,v 1.2 2001/12/21 15:07:21 simonmar Exp $
--
-- Complex numbers.
--
@@ -58,24 +58,30 @@ realPart, imagPart :: (RealFloat a) => Complex a -> a
realPart (x :+ _) = x
imagPart (_ :+ y) = y
+{-# SPECIALISE conjugate :: Complex Double -> Complex Double #-}
conjugate :: (RealFloat a) => Complex a -> Complex a
conjugate (x:+y) = x :+ (-y)
+{-# SPECIALISE mkPolar :: Double -> Double -> Complex Double #-}
mkPolar :: (RealFloat a) => a -> a -> Complex a
mkPolar r theta = r * cos theta :+ r * sin theta
+{-# SPECIALISE cis :: Double -> Complex Double #-}
cis :: (RealFloat a) => a -> Complex a
cis theta = cos theta :+ sin theta
+{-# SPECIALISE polar :: Complex Double -> (Double,Double) #-}
polar :: (RealFloat a) => Complex a -> (a,a)
polar z = (magnitude z, phase z)
+{-# SPECIALISE magnitude :: Complex Double -> Double #-}
magnitude :: (RealFloat a) => Complex a -> a
magnitude (x:+y) = scaleFloat k
(sqrt ((scaleFloat mk x)^(2::Int) + (scaleFloat mk y)^(2::Int)))
where k = max (exponent x) (exponent y)
mk = - k
+{-# SPECIALISE phase :: Complex Double -> Double #-}
phase :: (RealFloat a) => Complex a -> a
phase (0 :+ 0) = 0 -- SLPJ July 97 from John Peterson
phase (x:+y) = atan2 y x
diff --git a/libraries/base/Data/Dynamic.hs b/libraries/base/Data/Dynamic.hs
index e8643a3455..356d084532 100644
--- a/libraries/base/Data/Dynamic.hs
+++ b/libraries/base/Data/Dynamic.hs
@@ -9,7 +9,7 @@
-- Stability : experimental
-- Portability : portable
--
--- $Id: Dynamic.hs,v 1.3 2001/07/03 14:13:32 simonmar Exp $
+-- $Id: Dynamic.hs,v 1.4 2001/12/21 15:07:21 simonmar Exp $
--
-- The Dynamic interface provides basic support for dynamic types.
--
@@ -78,8 +78,6 @@ import GHC.Dynamic
#endif
#ifdef __GLASGOW_HASKELL__
-import GHC.Prim ( unsafeCoerce# )
-
unsafeCoerce :: a -> b
unsafeCoerce = unsafeCoerce#
#endif
diff --git a/libraries/base/Data/IORef.hs b/libraries/base/Data/IORef.hs
index dcc0eae1c0..910ea86e14 100644
--- a/libraries/base/Data/IORef.hs
+++ b/libraries/base/Data/IORef.hs
@@ -8,7 +8,7 @@
-- Stability : experimental
-- Portability : portable
--
--- $Id: IORef.hs,v 1.2 2001/07/03 11:37:49 simonmar Exp $
+-- $Id: IORef.hs,v 1.3 2001/12/21 15:07:21 simonmar Exp $
--
-- Mutable references in the IO monad.
--
@@ -29,7 +29,7 @@ module Data.IORef
import Prelude
#ifdef __GLASGOW_HASKELL__
-import GHC.Prim ( mkWeak# )
+import GHC.Base ( mkWeak# )
import GHC.STRef
import GHC.IOBase
#if !defined(__PARALLEL_HASKELL__)
diff --git a/libraries/base/Data/Ix.hs b/libraries/base/Data/Ix.hs
index 8d4d7452e2..5296e11e8d 100644
--- a/libraries/base/Data/Ix.hs
+++ b/libraries/base/Data/Ix.hs
@@ -8,7 +8,7 @@
-- Stability : provisional
-- Portability : portable
--
--- $Id: Ix.hs,v 1.1 2001/06/28 14:15:02 simonmar Exp $
+-- $Id: Ix.hs,v 1.2 2001/12/21 15:07:21 simonmar Exp $
--
-- Class of index types.
--
@@ -20,8 +20,8 @@ module Data.Ix
( range -- :: (Ix a) => (a,a) -> [a]
, index -- :: (Ix a) => (a,a) -> a -> Int
, inRange -- :: (Ix a) => (a,a) -> a -> Bool
+ , rangeSize -- :: (Ix a) => (a,a) -> Int
)
- , rangeSize -- :: (Ix a) => (a,a) -> Int
-- Ix instances:
--
-- Ix Char
diff --git a/libraries/base/Data/List.hs b/libraries/base/Data/List.hs
index ce4c9b32f2..9082db586a 100644
--- a/libraries/base/Data/List.hs
+++ b/libraries/base/Data/List.hs
@@ -9,7 +9,7 @@
-- Stability : provisional
-- Portability : portable
--
--- $Id: List.hs,v 1.1 2001/06/28 14:15:02 simonmar Exp $
+-- $Id: List.hs,v 1.2 2001/12/21 15:07:21 simonmar Exp $
--
-- Operations on lists.
--
@@ -317,13 +317,21 @@ insertBy cmp x ys@(y:ys')
GT -> y : insertBy cmp x ys'
_ -> x : ys
-maximumBy :: (a -> a -> a) -> [a] -> a
-maximumBy _ [] = error "List.maximumBy: empty list"
-maximumBy max xs = foldl1 max xs
-
-minimumBy :: (a -> a -> a) -> [a] -> a
-minimumBy _ [] = error "List.minimumBy: empty list"
-minimumBy min xs = foldl1 min xs
+maximumBy :: (a -> a -> Ordering) -> [a] -> a
+maximumBy _ [] = error "List.maximumBy: empty list"
+maximumBy cmp xs = foldl1 max xs
+ where
+ max x y = case cmp x y of
+ GT -> x
+ _ -> y
+
+minimumBy :: (a -> a -> Ordering) -> [a] -> a
+minimumBy _ [] = error "List.minimumBy: empty list"
+minimumBy cmp xs = foldl1 min xs
+ where
+ min x y = case cmp x y of
+ GT -> y
+ _ -> x
genericLength :: (Num i) => [b] -> i
genericLength [] = 0
diff --git a/libraries/base/Data/Tuple.hs b/libraries/base/Data/Tuple.hs
index f1fc78cd28..d37642add1 100644
--- a/libraries/base/Data/Tuple.hs
+++ b/libraries/base/Data/Tuple.hs
@@ -9,7 +9,7 @@
-- Stability : experimental
-- Portability : portable
--
--- $Id: Tuple.hs,v 1.1 2001/07/03 11:38:07 simonmar Exp $
+-- $Id: Tuple.hs,v 1.2 2001/12/21 15:07:22 simonmar Exp $
--
-- The tuple data types, and associated functions.
--
@@ -30,20 +30,20 @@ import GHC.Base
default () -- Double isn't available yet
#endif
-data (,) a b = (,) a b deriving (Eq, Ord)
+data (,) a b = (,) a b deriving (Eq, Ord)
data (,,) a b c = (,,) a b c deriving (Eq, Ord)
data (,,,) a b c d = (,,,) a b c d deriving (Eq, Ord)
data (,,,,) a b c d e = (,,,,) a b c d e deriving (Eq, Ord)
-data (,,,,,) a b c d e f = (,,,,,) a b c d e f
-data (,,,,,,) a b c d e f g = (,,,,,,) a b c d e f g
-data (,,,,,,,) a b c d e f g h = (,,,,,,,) a b c d e f g h
-data (,,,,,,,,) a b c d e f g h i = (,,,,,,,,) a b c d e f g h i
-data (,,,,,,,,,) a b c d e f g h i j = (,,,,,,,,,) a b c d e f g h i j
-data (,,,,,,,,,,) a b c d e f g h i j k = (,,,,,,,,,,) a b c d e f g h i j k
-data (,,,,,,,,,,,) a b c d e f g h i j k l = (,,,,,,,,,,,) a b c d e f g h i j k l
-data (,,,,,,,,,,,,) a b c d e f g h i j k l m = (,,,,,,,,,,,,) a b c d e f g h i j k l m
-data (,,,,,,,,,,,,,) a b c d e f g h i j k l m n = (,,,,,,,,,,,,,) a b c d e f g h i j k l m n
-data (,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o = (,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o
+data (,,,,,) a b c d e f = (,,,,,) a b c d e f deriving (Eq, Ord)
+data (,,,,,,) a b c d e f g = (,,,,,,) a b c d e f g deriving (Eq, Ord)
+data (,,,,,,,) a b c d e f g h = (,,,,,,,) a b c d e f g h deriving (Eq, Ord)
+data (,,,,,,,,) a b c d e f g h i = (,,,,,,,,) a b c d e f g h i deriving (Eq, Ord)
+data (,,,,,,,,,) a b c d e f g h i j = (,,,,,,,,,) a b c d e f g h i j deriving (Eq, Ord)
+data (,,,,,,,,,,) a b c d e f g h i j k = (,,,,,,,,,,) a b c d e f g h i j k deriving (Eq, Ord)
+data (,,,,,,,,,,,) a b c d e f g h i j k l = (,,,,,,,,,,,) a b c d e f g h i j k l deriving (Eq, Ord)
+data (,,,,,,,,,,,,) a b c d e f g h i j k l m = (,,,,,,,,,,,,) a b c d e f g h i j k l m deriving (Eq, Ord)
+data (,,,,,,,,,,,,,) a b c d e f g h i j k l m n = (,,,,,,,,,,,,,) a b c d e f g h i j k l m n deriving (Eq, Ord)
+data (,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o = (,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o deriving (Eq, Ord)
data (,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p = (,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p
data (,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q
= (,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q