Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed build on GHC 6.12

  • Loading branch information...
commit 4278391829b4b7ae0ee4768110af27620ccaac72 1 parent 90b14e7
@mokus0 authored
View
1  random-source/random-source.cabal
@@ -18,6 +18,7 @@ description: Random number generation based on entropy sources
\"completing\" partial implementations, making it
easy to define new entropy sources.
+tested-with: GHC == 6.12.1, GHC == 7.0.2
Flag mtl2
Description: mtl-2 has State, etc., as "type" rather than "newtype"
View
3  random-source/src/Data/Random/Internal/Source.hs
@@ -1,5 +1,6 @@
{-# LANGUAGE
- MultiParamTypeClasses, FlexibleInstances, TemplateHaskell, GADTs, RankNTypes
+ TemplateHaskell, GADTs, RankNTypes,
+ MultiParamTypeClasses, FlexibleInstances, FlexibleContexts
#-}
module Data.Random.Internal.Source
View
16 random-source/src/Data/Random/Internal/TH.hs
@@ -1,5 +1,5 @@
{-# LANGUAGE TemplateHaskell, GADTs #-}
-{-# OPTIONS_GHC -fno-warn-type-defaults #-}
+{-# OPTIONS_GHC -fno-warn-type-defaults -fno-warn-missing-signatures #-}
module Data.Random.Internal.TH (monadRandom, randomSource) where
import Data.Bits
@@ -127,6 +127,10 @@ specialize decQ = do
return (map (addSrcParam src) . specializeDec $ decs)
else return (fmap specializeDec decQ)
+stripTypeSigs :: Q [Dec] -> Q [Dec]
+stripTypeSigs = fmap (filter (not . isSig))
+ where isSig SigD{} = True; isSig _ = False
+
addSrcParam :: Name -> Dec -> Dec
addSrcParam src
= everywhere (mkT expandDecs)
@@ -178,8 +182,14 @@ defaults = runReaderT $
method GetPrim $ do
implementation $ do
mapM_ dependsOn (allMethods \\ [GetPrim])
- specialize
- [d| getPrim PrimWord8 = $getWord8
+
+ -- GHC 6 requires type signatures for GADT matches, even
+ -- inside [d||]. This code is evaluated at more than one type, though,
+ -- and at its eventual splice site the signature actually isn't even allowed.
+ -- So, there's a dummy signature here which is immediately stripped out.
+ specialize . stripTypeSigs $
+ [d| getPrim :: Prim a -> m a
+ getPrim PrimWord8 = $getWord8
getPrim PrimWord16 = $getWord16
getPrim PrimWord32 = $getWord32
getPrim PrimWord64 = $getWord64
View
2  random-source/src/Data/Random/Source/PureMT.hs
@@ -81,7 +81,7 @@ $(monadRandom
|])
$(randomSource
- [d| instance (Monad m, ModifyRef (IORef PureMT) m PureMT) => RandomSource m (IORef PureMT) where
+ [d| instance (MonadIO m) => RandomSource m (IORef PureMT) where
getRandomWord64From = withMTRef randomWord64
getRandomDoubleFrom = withMTRef randomDouble
|])
Please sign in to comment.
Something went wrong with that request. Please try again.