From 57311d96e4ff514d4f271e30292a19a75415e924 Mon Sep 17 00:00:00 2001 From: ross Date: Fri, 14 Jan 2005 12:18:02 +0000 Subject: [PATCH] [project @ 2005-01-14 12:18:00 by ross] Hugs: include instances for Word --- Data/Array/Base.hs | 18 ++++++++++-------- Data/Array/Diff.hs | 4 ---- Data/Array/IO/Internals.hs | 2 -- Data/Typeable.hs | 4 +++- Foreign/Storable.hs | 2 +- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Data/Array/Base.hs b/Data/Array/Base.hs index 61e89e4..b284cf4 100644 --- a/Data/Array/Base.hs +++ b/Data/Array/Base.hs @@ -546,19 +546,22 @@ instance IArray UArray Int where {-# INLINE unsafeAccumArray #-} unsafeAccumArray f init lu ies = runST (unsafeAccumArrayUArray f init lu ies) -#ifdef __GLASGOW_HASKELL__ instance IArray UArray Word where {-# INLINE unsafeArray #-} unsafeArray lu ies = runST (unsafeArrayUArray lu ies 0) +#ifdef __GLASGOW_HASKELL__ {-# INLINE unsafeAt #-} unsafeAt (UArray _ _ arr#) (I# i#) = W# (indexWordArray# arr# i#) +#endif +#ifdef __HUGS__ + unsafeAt = unsafeAtBArray +#endif {-# INLINE unsafeReplace #-} unsafeReplace arr ies = runST (unsafeReplaceUArray arr ies) {-# INLINE unsafeAccum #-} unsafeAccum f arr ies = runST (unsafeAccumUArray f arr ies) {-# INLINE unsafeAccumArray #-} unsafeAccumArray f init lu ies = runST (unsafeAccumArrayUArray f init lu ies) -#endif instance IArray UArray (Ptr a) where {-# INLINE unsafeArray #-} @@ -798,10 +801,8 @@ instance Ix ix => Eq (UArray ix Char) where instance Ix ix => Eq (UArray ix Int) where (==) = eqUArray -#ifdef __GLASGOW_HASKELL__ instance Ix ix => Eq (UArray ix Word) where (==) = eqUArray -#endif instance Ix ix => Eq (UArray ix (Ptr a)) where (==) = eqUArray @@ -853,10 +854,8 @@ instance Ix ix => Ord (UArray ix Char) where instance Ix ix => Ord (UArray ix Int) where compare = cmpUArray -#ifdef __GLASGOW_HASKELL__ instance Ix ix => Ord (UArray ix Word) where compare = cmpUArray -#endif instance Ix ix => Ord (UArray ix (Ptr a)) where compare = cmpUArray @@ -903,10 +902,8 @@ instance (Ix ix, Show ix) => Show (UArray ix Char) where instance (Ix ix, Show ix) => Show (UArray ix Int) where showsPrec = showsIArray -#ifdef __GLASGOW_HASKELL__ instance (Ix ix, Show ix) => Show (UArray ix Word) where showsPrec = showsIArray -#endif instance (Ix ix, Show ix) => Show (UArray ix Float) where showsPrec = showsIArray @@ -1450,6 +1447,11 @@ instance MArray (STUArray s) Int (ST s) where unsafeRead = unsafeReadMBArray unsafeWrite = unsafeWriteMBArray +instance MArray (STUArray s) Word (ST s) where + newArray_ = newMBArray_ + unsafeRead = unsafeReadMBArray + unsafeWrite = unsafeWriteMBArray + instance MArray (STUArray s) (Ptr a) (ST s) where newArray_ = newMBArray_ unsafeRead = unsafeReadMBArray diff --git a/Data/Array/Diff.hs b/Data/Array/Diff.hs index 59ff871..0b5f0b4 100644 --- a/Data/Array/Diff.hs +++ b/Data/Array/Diff.hs @@ -128,10 +128,8 @@ instance (Ix ix, Show ix) => Show (DiffUArray ix Char) where instance (Ix ix, Show ix) => Show (DiffUArray ix Int) where showsPrec = showsIArray -#ifdef __GLASGOW_HASKELL__ instance (Ix ix, Show ix) => Show (DiffUArray ix Word) where showsPrec = showsIArray -#endif instance (Ix ix, Show ix) => Show (DiffUArray ix Float) where showsPrec = showsIArray @@ -184,12 +182,10 @@ instance IArray (IOToDiffArray IOUArray) Int where unsafeAt a i = unsafePerformIO $ a `readDiffArray` i unsafeReplace a ies = unsafePerformIO $ a `replaceDiffArray2` ies -#ifdef __GLASGOW_HASKELL__ instance IArray (IOToDiffArray IOUArray) Word where unsafeArray lu ies = unsafePerformIO $ newDiffArray lu ies unsafeAt a i = unsafePerformIO $ a `readDiffArray` i unsafeReplace a ies = unsafePerformIO $ a `replaceDiffArray2` ies -#endif instance IArray (IOToDiffArray IOUArray) (Ptr a) where unsafeArray lu ies = unsafePerformIO $ newDiffArray lu ies diff --git a/Data/Array/IO/Internals.hs b/Data/Array/IO/Internals.hs index fda59f0..245acfc 100644 --- a/Data/Array/IO/Internals.hs +++ b/Data/Array/IO/Internals.hs @@ -119,7 +119,6 @@ instance MArray IOUArray Int IO where {-# INLINE unsafeWrite #-} unsafeWrite (IOUArray marr) i e = stToIO (unsafeWrite marr i e) -#ifdef __GLASGOW_HASKELL__ instance MArray IOUArray Word IO where {-# INLINE newArray #-} newArray lu init = stToIO $ do @@ -131,7 +130,6 @@ instance MArray IOUArray Word IO where unsafeRead (IOUArray marr) i = stToIO (unsafeRead marr i) {-# INLINE unsafeWrite #-} unsafeWrite (IOUArray marr) i e = stToIO (unsafeWrite marr i e) -#endif instance MArray IOUArray (Ptr a) IO where {-# INLINE newArray #-} diff --git a/Data/Typeable.hs b/Data/Typeable.hs index f5b1c82..2369b80 100644 --- a/Data/Typeable.hs +++ b/Data/Typeable.hs @@ -512,6 +512,9 @@ INSTANCE_TYPEABLE0(Char,charTc,"Char") INSTANCE_TYPEABLE0(Float,floatTc,"Float") INSTANCE_TYPEABLE0(Double,doubleTc,"Double") INSTANCE_TYPEABLE0(Int,intTc,"Int") +#ifndef __NHC__ +INSTANCE_TYPEABLE0(Word,wordTc,"Word" ) +#endif INSTANCE_TYPEABLE0(Integer,integerTc,"Integer") INSTANCE_TYPEABLE0(Ordering,orderingTc,"Ordering") INSTANCE_TYPEABLE0(Handle,handleTc,"Handle") @@ -531,7 +534,6 @@ INSTANCE_TYPEABLE0(TypeRep,typeRepTc,"TypeRep") #ifdef __GLASGOW_HASKELL__ INSTANCE_TYPEABLE0(RealWorld,realWorldTc,"RealWorld") -INSTANCE_TYPEABLE0(Word,wordTc,"Word" ) INSTANCE_TYPEABLE1(MVar,mvarTc,"MVar" ) #endif diff --git a/Foreign/Storable.hs b/Foreign/Storable.hs index bff2869..cfe0524 100644 --- a/Foreign/Storable.hs +++ b/Foreign/Storable.hs @@ -199,7 +199,7 @@ STORABLE(Char,SIZEOF_HSCHAR,ALIGNMENT_HSCHAR, STORABLE(Int,SIZEOF_HSINT,ALIGNMENT_HSINT, readIntOffPtr,writeIntOffPtr) -#ifdef __GLASGOW_HASKELL__ +#ifndef __NHC__ STORABLE(Word,SIZEOF_HSWORD,ALIGNMENT_HSWORD, readWordOffPtr,writeWordOffPtr) #endif -- 1.7.10.4