diff --git a/Data/Array/Static.hs b/Data/Array/Static.hs index d9fb126..6ecbcec 100644 --- a/Data/Array/Static.hs +++ b/Data/Array/Static.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE MagicHash #-} +{-# LANGUAGE MagicHash,BangPatterns #-} module Data.Array.Static where import Data.Static @@ -11,5 +11,5 @@ bounds :: Ix i => StaticArray i e -> (i,i) bounds (StaticArray s e _) = (s,e) (!) :: (StaticElement e,Ix i) => StaticArray i e -> i -> e -(!) (StaticArray s e addr) i = let (I# ri) = index (s,e) i +(!) (StaticArray s e addr) i = let !(I# ri) = index (s,e) i in extract addr ri diff --git a/Data/Static.hs b/Data/Static.hs index effcb11..15ce36d 100644 --- a/Data/Static.hs +++ b/Data/Static.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE MagicHash,FlexibleInstances,BangPatterns #-} +{-# LANGUAGE MagicHash,FlexibleInstances,BangPatterns,CPP #-} module Data.Static where import GHC.Exts @@ -36,7 +36,11 @@ instance StaticElement Char where instance StaticElement (Maybe Char) where extract addr i = let !v = indexWord32OffAddr# addr i +#if __GLASGOW_HASKELL__ >= 708 + in if isTrue# (eqWord# v (int2Word# 4294967295#)) -- -1 in Word32 +#else in if eqWord# v (int2Word# 4294967295#) -- -1 in Word32 +#endif then Nothing else (if (I# (word2Int# v)) > 0x10FFFF then error (show (I# (word2Int# v))++" is not a valid char ("++show (I# i)++")")