From 00f914ebde017701fbb45f9be34360673a1b0393 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Sat, 24 May 2014 18:56:03 -0700 Subject: [PATCH] =?UTF-8?q?GHC=207.8=20compatibility,=20based=20on=20a=20p?= =?UTF-8?q?atch=20suggested=20by=20Jos=C3=A9=20Romildo=20Malaquias?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ignore-this: 4a655a3a1d2348054d2028f5c26dc0d5 darcs-hash:20140525015603-7469c-30d96daeffde6da775c2b8f6579c0a2fbbfc479a --- Data/Array/Static.hs | 4 ++-- Data/Static.hs | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) 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)++")")