Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 1343a3c

Browse files
Remove pre-ghc-7.10 conditional compilation.
1 parent 22d9391 commit 1343a3c

File tree

1 file changed

+0
-34
lines changed

1 file changed

+0
-34
lines changed

src/Control/Distributed/Static.hs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,15 @@
167167
-- > where
168168
-- > sdictSendPort :: forall a. SerializableDict a -> SerializableDict (SendPort a)
169169
-- > sdictSendPort SerializableDict = SerializableDict
170-
{-# LANGUAGE CPP #-}
171-
#if __GLASGOW_HASKELL__ >= 710
172170
{-# LANGUAGE StaticPointers #-}
173171
{-# LANGUAGE RoleAnnotations #-}
174-
#endif
175172
module Control.Distributed.Static
176173
( -- * Static values
177174
Static
178175
, staticLabel
179176
, staticApply
180-
#if __GLASGOW_HASKELL__ >= 710
181177
, staticPtr
182178
, staticApplyPtr
183-
#endif
184179
-- * Derived static combinators
185180
, staticCompose
186181
, staticSplit
@@ -213,9 +208,6 @@ import Data.Binary
213208
, decode
214209
)
215210
import Data.ByteString.Lazy (ByteString, empty)
216-
#if ! MIN_VERSION_bytestring(0,10,0)
217-
import Data.ByteString.Lazy as BSL
218-
#endif
219211
import Data.Map (Map)
220212
import qualified Data.Map as Map (lookup, empty, insert)
221213
import Control.Applicative ((<$>), (<*>))
@@ -228,27 +220,22 @@ import Data.Rank1Typeable
228220
, ANY2
229221
, ANY3
230222
, ANY4
231-
#if __GLASGOW_HASKELL__ >= 710
232223
, TypeRep
233224
, typeOf
234-
#endif
235225
)
236226

237227
-- Imports necessary to support StaticPtr
238-
#if __GLASGOW_HASKELL__ >= 710
239228
import qualified GHC.Exts as GHC (Any)
240229
import GHC.StaticPtr
241230
import GHC.Fingerprint.Type (Fingerprint(..))
242231
import System.IO.Unsafe (unsafePerformIO)
243232
import Data.Rank1Dynamic (unsafeToDynamic)
244233
import Unsafe.Coerce (unsafeCoerce)
245-
#endif
246234

247235
--------------------------------------------------------------------------------
248236
-- Introducing static values --
249237
--------------------------------------------------------------------------------
250238

251-
#if __GLASGOW_HASKELL__ >= 710
252239
-- | Static dynamic values
253240
--
254241
-- In the new proposal for static, the SPT contains these 'TypeRep's.
@@ -272,32 +259,25 @@ instance Eq SDynamic where
272259
instance Ord SDynamic where
273260
SDynamic _ ptr1 `compare` SDynamic _ ptr2 =
274261
staticKey ptr1 `compare` staticKey ptr2
275-
#endif
276262

277263
data StaticLabel =
278264
StaticLabel String
279265
| StaticApply !StaticLabel !StaticLabel
280-
#if __GLASGOW_HASKELL__ >= 710
281266
| StaticPtr SDynamic
282-
#endif
283267
deriving (Eq, Ord, Typeable, Show)
284268

285269
instance NFData StaticLabel where
286270
rnf (StaticLabel s) = rnf s
287271
rnf (StaticApply a b) = rnf a `seq` rnf b
288272
-- There are no NFData instances for TypeRep or for StaticPtr :/
289-
#if __GLASGOW_HASKELL__ >= 710
290273
rnf (StaticPtr (SDynamic _a _b)) = ()
291-
#endif
292274

293275
-- | A static value. Static is opaque; see 'staticLabel' and 'staticApply'.
294276
newtype Static a = Static StaticLabel
295277
deriving (Eq, Ord, Typeable, Show)
296278

297279
-- Trying to 'coerce' static values will lead to unification errors
298-
#if __GLASGOW_HASKELL__ >= 710
299280
type role Static nominal
300-
#endif
301281

302282
instance NFData (Static a) where
303283
rnf (Static s) = rnf s
@@ -312,35 +292,29 @@ putStaticLabel (StaticLabel string) =
312292
putWord8 0 >> put string
313293
putStaticLabel (StaticApply label1 label2) =
314294
putWord8 1 >> putStaticLabel label1 >> putStaticLabel label2
315-
#if __GLASGOW_HASKELL__ >= 710
316295
putStaticLabel (StaticPtr (SDynamic typ ptr)) =
317296
let Fingerprint hi lo = staticKey ptr
318297
in putWord8 2 >> put typ >> put hi >> put lo
319-
#endif
320298

321299
getStaticLabel :: Get StaticLabel
322300
getStaticLabel = do
323301
header <- getWord8
324302
case header of
325303
0 -> StaticLabel <$> get
326304
1 -> StaticApply <$> getStaticLabel <*> getStaticLabel
327-
#if __GLASGOW_HASKELL__ >= 710
328305
2 -> do typ <- get
329306
hi <- get
330307
lo <- get
331308
let key = Fingerprint hi lo
332309
case unsaferLookupStaticPtr key of
333310
Nothing -> fail "StaticLabel.get: invalid pointer"
334311
Just ptr -> return $ StaticPtr (SDynamic typ ptr)
335-
#endif
336312
_ -> fail "StaticLabel.get: invalid"
337313

338-
#if __GLASGOW_HASKELL__ >= 710
339314
-- | We need to be able to lookup keys outside of the IO monad so that we
340315
-- can provide a 'Get' instance.
341316
unsaferLookupStaticPtr :: StaticKey -> Maybe (StaticPtr a)
342317
unsaferLookupStaticPtr = unsafePerformIO . unsafeLookupStaticPtr
343-
#endif
344318

345319
-- | Create a primitive static value.
346320
--
@@ -353,7 +327,6 @@ staticLabel = Static . StaticLabel . force
353327
staticApply :: Static (a -> b) -> Static a -> Static b
354328
staticApply (Static f) (Static x) = Static (StaticApply f x)
355329

356-
#if __GLASGOW_HASKELL__ >= 710
357330
-- | Construct a static value from a static pointer
358331
--
359332
-- Since 0.3.4.0.
@@ -367,7 +340,6 @@ staticPtr x = Static . StaticPtr
367340
staticApplyPtr :: (Typeable a, Typeable b)
368341
=> StaticPtr (a -> b) -> Static a -> Static b
369342
staticApplyPtr = staticApply . staticPtr
370-
#endif
371343

372344
--------------------------------------------------------------------------------
373345
-- Eliminating static values --
@@ -402,10 +374,8 @@ resolveStaticLabel rtable (StaticApply label1 label2) = do
402374
f <- resolveStaticLabel rtable label1
403375
x <- resolveStaticLabel rtable label2
404376
f `dynApply` x
405-
#if __GLASGOW_HASKELL__ >= 710
406377
resolveStaticLabel _ (StaticPtr (SDynamic typ ptr)) =
407378
return $ unsafeToDynamic typ (deRefStaticPtr ptr)
408-
#endif
409379

410380
-- | Resolve a static value
411381
unstatic :: Typeable a => RemoteTable -> Static a -> Either String a
@@ -425,11 +395,7 @@ instance Binary (Closure a) where
425395
put (Closure st env) = put st >> put env
426396
get = Closure <$> get <*> get
427397

428-
#if MIN_VERSION_bytestring(0,10,0)
429398
instance NFData (Closure a) where rnf (Closure f b) = rnf f `seq` rnf b
430-
#else
431-
instance NFData (Closure a) where rnf (Closure f b) = rnf f `seq` BSL.length b `seq` ()
432-
#endif
433399

434400
closure :: Static (ByteString -> a) -- ^ Decoder
435401
-> ByteString -- ^ Encoded closure environment

0 commit comments

Comments
 (0)