From: Ian Lynagh Date: Wed, 20 Aug 2008 23:04:37 +0000 (+0000) Subject: Fix warnings in Data.Generics.* X-Git-Tag: 6_10_branch_has_been_forked~34 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=22da0261c577c59579d9540705d0cd537a6a1887;p=ghc-base.git Fix warnings in Data.Generics.* --- diff --git a/Data/Generics/Aliases.hs b/Data/Generics/Aliases.hs index 024c3de..0d8e95b 100644 --- a/Data/Generics/Aliases.hs +++ b/Data/Generics/Aliases.hs @@ -310,23 +310,23 @@ recoverQ r f = f `choiceQ` const (return r) -- | Flexible type extension ext1 :: (Data a, Typeable1 t) => c a - -> (forall a. Data a => c (t a)) + -> (forall d. Data d => c (t d)) -> c a ext1 def ext = maybe def id (dataCast1 ext) -- | Type extension of transformations for unary type constructors ext1T :: (Data d, Typeable1 t) - => (forall d. Data d => d -> d) - -> (forall d. Data d => t d -> t d) + => (forall e. Data e => e -> e) + -> (forall f. Data f => t f -> t f) -> d -> d ext1T def ext = unT ((T def) `ext1` (T ext)) -- | Type extension of monadic transformations for type constructors ext1M :: (Monad m, Data d, Typeable1 t) - => (forall d. Data d => d -> m d) - -> (forall d. Data d => t d -> m (t d)) + => (forall e. Data e => e -> m e) + -> (forall f. Data f => t f -> m (t f)) -> d -> m d ext1M def ext = unM ((M def) `ext1` (M ext)) @@ -334,7 +334,7 @@ ext1M def ext = unM ((M def) `ext1` (M ext)) -- | Type extension of queries for type constructors ext1Q :: (Data d, Typeable1 t) => (d -> q) - -> (forall d. Data d => t d -> q) + -> (forall e. Data e => t e -> q) -> d -> q ext1Q def ext = unQ ((Q def) `ext1` (Q ext)) @@ -342,7 +342,7 @@ ext1Q def ext = unQ ((Q def) `ext1` (Q ext)) -- | Type extension of readers for type constructors ext1R :: (Monad m, Data d, Typeable1 t) => m d - -> (forall d. Data d => m (t d)) + -> (forall e. Data e => m (t e)) -> m d ext1R def ext = unR ((R def) `ext1` (R ext)) diff --git a/Data/Generics/Basics.hs b/Data/Generics/Basics.hs index 89fe3a8..df4ad0e 100644 --- a/Data/Generics/Basics.hs +++ b/Data/Generics/Basics.hs @@ -185,7 +185,7 @@ class Typeable a => Data a where -- -- The default definition for 'gfoldl' is @'const' 'id'@, which is -- suitable for abstract datatypes with no substructures. - gfoldl :: (forall a b. Data a => c (a -> b) -> a -> c b) + gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -- ^ defines how nonempty constructor applications are -- folded. It takes the folded tail of the constructor -- application and its head, i.e., an immediate subterm, @@ -236,7 +236,7 @@ class Typeable a => Data a where -- The default definition is @'const' 'Nothing'@, which is appropriate -- for non-unary type constructors. dataCast1 :: Typeable1 t - => (forall a. Data a => c (t a)) + => (forall d. Data d => c (t d)) -> Maybe (c a) dataCast1 _ = Nothing @@ -247,7 +247,7 @@ class Typeable a => Data a where -- The default definition is @'const' 'Nothing'@, which is appropriate -- for non-binary type constructors. dataCast2 :: Typeable2 t - => (forall a b. (Data a, Data b) => c (t a b)) + => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a) dataCast2 _ = Nothing @@ -271,21 +271,21 @@ class Typeable a => Data a where -- to instantiate the type constructor c in the type of gfoldl, -- and perform injections ID and projections unID accordingly. -- - gmapT f x = unID (gfoldl k ID x) + gmapT f x0 = unID (gfoldl k ID x0) where k (ID c) x = ID (c (f x)) -- | A generic query with a left-associative binary operator - gmapQl :: (r -> r' -> r) -> r -> (forall a. Data a => a -> r') -> a -> r + gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r gmapQl o r f = unCONST . gfoldl k z where k c x = CONST $ (unCONST c) `o` f x z _ = CONST r -- | A generic query with a right-associative binary operator - gmapQr :: (r' -> r -> r) -> r -> (forall a. Data a => a -> r') -> a -> r - gmapQr o r f x = unQr (gfoldl k (const (Qr id)) x) r + gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r + gmapQr o r0 f x0 = unQr (gfoldl k (const (Qr id)) x0) r0 where k (Qr c) x = Qr (\r -> c (f x `o` r)) @@ -293,16 +293,16 @@ class Typeable a => Data a where -- | A generic query that processes the immediate subterms and returns a list -- of results. The list is given in the same order as originally specified -- in the declaratoin of the data constructors. - gmapQ :: (forall a. Data a => a -> u) -> a -> [u] + gmapQ :: (forall d. Data d => d -> u) -> a -> [u] gmapQ f = gmapQr (:) [] f -- | A generic query that processes one child by index (zero-based) - gmapQi :: Int -> (forall a. Data a => a -> u) -> a -> u + gmapQi :: Int -> (forall d. Data d => d -> u) -> a -> u gmapQi i f x = case gfoldl k z x of { Qi _ q -> fromJust q } where k (Qi i' q) a = Qi (i'+1) (if i==i' then Just (f a) else q) - z f = Qi 0 Nothing + z _ = Qi 0 Nothing -- | A generic monadic transformation that maps over the immediate subterms @@ -310,7 +310,7 @@ class Typeable a => Data a where -- The default definition instantiates the type constructor @c@ in -- the type of 'gfoldl' to the monad datatype constructor, defining -- injection and projection using 'return' and '>>='. - gmapM :: Monad m => (forall a. Data a => a -> m a) -> a -> m a + gmapM :: Monad m => (forall d. Data d => d -> m d) -> a -> m a -- Use immediately the monad datatype constructor -- to instantiate the type constructor c in the type of gfoldl, @@ -324,7 +324,7 @@ class Typeable a => Data a where -- | Transformation of at least one immediate subterm does not fail - gmapMp :: MonadPlus m => (forall a. Data a => a -> m a) -> a -> m a + gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> a -> m a {- @@ -338,14 +338,14 @@ this end, we couple the monadic computation with a Boolean. if b then return x' else mzero where z g = Mp (return (g,False)) - k (Mp c) x - = Mp ( c >>= \(h,b) -> - (f x >>= \x' -> return (h x',True)) - `mplus` return (h x,b) + k (Mp c) y + = Mp ( c >>= \(h, b) -> + (f y >>= \y' -> return (h y', True)) + `mplus` return (h y, b) ) -- | Transformation of one immediate subterm with success - gmapMo :: MonadPlus m => (forall a. Data a => a -> m a) -> a -> m a + gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> a -> m a {- @@ -361,11 +361,11 @@ was transformed successfully. if b then return x' else mzero where z g = Mp (return (g,False)) - k (Mp c) x + k (Mp c) y = Mp ( c >>= \(h,b) -> if b - then return (h x,b) - else (f x >>= \x' -> return (h x',True)) - `mplus` return (h x,b) + then return (h y, b) + else (f y >>= \y' -> return (h y',True)) + `mplus` return (h y, b) ) @@ -404,7 +404,7 @@ fromConstr = fromConstrB undefined -- | Build a term and use a generic function for subterms fromConstrB :: Data a - => (forall a. Data a => a) + => (forall d. Data d => d) -> Constr -> a fromConstrB f = unID . gunfold k z @@ -415,7 +415,7 @@ fromConstrB f = unID . gunfold k z -- | Monadic variation on 'fromConstrB' fromConstrM :: (Monad m, Data a) - => (forall a. Data a => m a) + => (forall d. Data d => m d) -> Constr -> m a fromConstrM f = gunfold k z @@ -762,5 +762,5 @@ tyconModule x = let (a,b) = break ((==) '.') x then b else a ++ tyconModule' (tail b) where - tyconModule' x = let x' = tyconModule x - in if x' == "" then "" else ('.':x') + tyconModule' y = let y' = tyconModule y + in if y' == "" then "" else ('.':y') diff --git a/Data/Generics/Instances.hs b/Data/Generics/Instances.hs index 0745b05..daa11bf 100644 --- a/Data/Generics/Instances.hs +++ b/Data/Generics/Instances.hs @@ -15,6 +15,7 @@ -- ----------------------------------------------------------------------------- +{-# OPTIONS_GHC -fno-warn-orphans #-} module Data.Generics.Instances where @@ -49,15 +50,18 @@ import GHC.Arr -- So we can give Data instance for Array ------------------------------------------------------------------------------ +falseConstr :: Constr falseConstr = mkConstr boolDataType "False" [] Prefix +trueConstr :: Constr trueConstr = mkConstr boolDataType "True" [] Prefix -boolDataType = mkDataType "Prelude.Bool" [falseConstr,trueConstr] +boolDataType :: DataType +boolDataType = mkDataType "Prelude.Bool" [falseConstr,trueConstr] instance Data Bool where toConstr False = falseConstr toConstr True = trueConstr - gunfold k z c = case constrIndex c of + gunfold _ z c = case constrIndex c of 1 -> z False 2 -> z True _ -> error "gunfold" @@ -66,12 +70,12 @@ instance Data Bool where ------------------------------------------------------------------------------ - +charType :: DataType charType = mkStringType "Prelude.Char" instance Data Char where toConstr x = mkStringConstr charType [x] - gunfold k z c = case constrRep c of + gunfold _ z c = case constrRep c of (StringConstr [x]) -> z x _ -> error "gunfold" dataTypeOf _ = charType @@ -79,12 +83,12 @@ instance Data Char where ------------------------------------------------------------------------------ - +floatType :: DataType floatType = mkFloatType "Prelude.Float" instance Data Float where toConstr x = mkFloatConstr floatType (realToFrac x) - gunfold k z c = case constrRep c of + gunfold _ z c = case constrRep c of (FloatConstr x) -> z (realToFrac x) _ -> error "gunfold" dataTypeOf _ = floatType @@ -92,12 +96,12 @@ instance Data Float where ------------------------------------------------------------------------------ - +doubleType :: DataType doubleType = mkFloatType "Prelude.Double" instance Data Double where toConstr = mkFloatConstr floatType - gunfold k z c = case constrRep c of + gunfold _ z c = case constrRep c of (FloatConstr x) -> z x _ -> error "gunfold" dataTypeOf _ = doubleType @@ -105,12 +109,12 @@ instance Data Double where ------------------------------------------------------------------------------ - +intType :: DataType intType = mkIntType "Prelude.Int" instance Data Int where toConstr x = mkIntConstr intType (fromIntegral x) - gunfold k z c = case constrRep c of + gunfold _ z c = case constrRep c of (IntConstr x) -> z (fromIntegral x) _ -> error "gunfold" dataTypeOf _ = intType @@ -118,12 +122,12 @@ instance Data Int where ------------------------------------------------------------------------------ - +integerType :: DataType integerType = mkIntType "Prelude.Integer" instance Data Integer where toConstr = mkIntConstr integerType - gunfold k z c = case constrRep c of + gunfold _ z c = case constrRep c of (IntConstr x) -> z x _ -> error "gunfold" dataTypeOf _ = integerType @@ -131,12 +135,12 @@ instance Data Integer where ------------------------------------------------------------------------------ - +int8Type :: DataType int8Type = mkIntType "Data.Int.Int8" instance Data Int8 where toConstr x = mkIntConstr int8Type (fromIntegral x) - gunfold k z c = case constrRep c of + gunfold _ z c = case constrRep c of (IntConstr x) -> z (fromIntegral x) _ -> error "gunfold" dataTypeOf _ = int8Type @@ -144,12 +148,12 @@ instance Data Int8 where ------------------------------------------------------------------------------ - +int16Type :: DataType int16Type = mkIntType "Data.Int.Int16" instance Data Int16 where toConstr x = mkIntConstr int16Type (fromIntegral x) - gunfold k z c = case constrRep c of + gunfold _ z c = case constrRep c of (IntConstr x) -> z (fromIntegral x) _ -> error "gunfold" dataTypeOf _ = int16Type @@ -157,12 +161,12 @@ instance Data Int16 where ------------------------------------------------------------------------------ - +int32Type :: DataType int32Type = mkIntType "Data.Int.Int32" instance Data Int32 where toConstr x = mkIntConstr int32Type (fromIntegral x) - gunfold k z c = case constrRep c of + gunfold _ z c = case constrRep c of (IntConstr x) -> z (fromIntegral x) _ -> error "gunfold" dataTypeOf _ = int32Type @@ -170,12 +174,12 @@ instance Data Int32 where ------------------------------------------------------------------------------ - +int64Type :: DataType int64Type = mkIntType "Data.Int.Int64" instance Data Int64 where toConstr x = mkIntConstr int64Type (fromIntegral x) - gunfold k z c = case constrRep c of + gunfold _ z c = case constrRep c of (IntConstr x) -> z (fromIntegral x) _ -> error "gunfold" dataTypeOf _ = int64Type @@ -183,12 +187,12 @@ instance Data Int64 where ------------------------------------------------------------------------------ - +wordType :: DataType wordType = mkIntType "Data.Word.Word" instance Data Word where toConstr x = mkIntConstr wordType (fromIntegral x) - gunfold k z c = case constrRep c of + gunfold _ z c = case constrRep c of (IntConstr x) -> z (fromIntegral x) _ -> error "gunfold" dataTypeOf _ = wordType @@ -196,12 +200,12 @@ instance Data Word where ------------------------------------------------------------------------------ - +word8Type :: DataType word8Type = mkIntType "Data.Word.Word8" instance Data Word8 where toConstr x = mkIntConstr word8Type (fromIntegral x) - gunfold k z c = case constrRep c of + gunfold _ z c = case constrRep c of (IntConstr x) -> z (fromIntegral x) _ -> error "gunfold" dataTypeOf _ = word8Type @@ -209,12 +213,12 @@ instance Data Word8 where ------------------------------------------------------------------------------ - +word16Type :: DataType word16Type = mkIntType "Data.Word.Word16" instance Data Word16 where toConstr x = mkIntConstr word16Type (fromIntegral x) - gunfold k z c = case constrRep c of + gunfold _ z c = case constrRep c of (IntConstr x) -> z (fromIntegral x) _ -> error "gunfold" dataTypeOf _ = word16Type @@ -222,12 +226,12 @@ instance Data Word16 where ------------------------------------------------------------------------------ - +word32Type :: DataType word32Type = mkIntType "Data.Word.Word32" instance Data Word32 where toConstr x = mkIntConstr word32Type (fromIntegral x) - gunfold k z c = case constrRep c of + gunfold _ z c = case constrRep c of (IntConstr x) -> z (fromIntegral x) _ -> error "gunfold" dataTypeOf _ = word32Type @@ -235,12 +239,12 @@ instance Data Word32 where ------------------------------------------------------------------------------ - +word64Type :: DataType word64Type = mkIntType "Data.Word.Word64" instance Data Word64 where toConstr x = mkIntConstr word64Type (fromIntegral x) - gunfold k z c = case constrRep c of + gunfold _ z c = case constrRep c of (IntConstr x) -> z (fromIntegral x) _ -> error "gunfold" dataTypeOf _ = word64Type @@ -248,8 +252,10 @@ instance Data Word64 where ------------------------------------------------------------------------------ - +ratioConstr :: Constr ratioConstr = mkConstr ratioDataType ":%" [] Infix + +ratioDataType :: DataType ratioDataType = mkDataType "GHC.Real.Ratio" [ratioConstr] instance (Data a, Integral a) => Data (Ratio a) where @@ -261,13 +267,16 @@ instance (Data a, Integral a) => Data (Ratio a) where ------------------------------------------------------------------------------ - +nilConstr :: Constr nilConstr = mkConstr listDataType "[]" [] Prefix +consConstr :: Constr consConstr = mkConstr listDataType "(:)" [] Infix + +listDataType :: DataType listDataType = mkDataType "Prelude.[]" [nilConstr,consConstr] instance Data a => Data [a] where - gfoldl f z [] = z [] + gfoldl _ z [] = z [] gfoldl f z (x:xs) = z (:) `f` x `f` xs toConstr [] = nilConstr toConstr (_:_) = consConstr @@ -282,23 +291,26 @@ instance Data a => Data [a] where -- The gmaps are given as an illustration. -- This shows that the gmaps for lists are different from list maps. -- - gmapT f [] = [] + gmapT _ [] = [] gmapT f (x:xs) = (f x:f xs) - gmapQ f [] = [] + gmapQ _ [] = [] gmapQ f (x:xs) = [f x,f xs] - gmapM f [] = return [] + gmapM _ [] = return [] gmapM f (x:xs) = f x >>= \x' -> f xs >>= \xs' -> return (x':xs') ------------------------------------------------------------------------------ - +nothingConstr :: Constr nothingConstr = mkConstr maybeDataType "Nothing" [] Prefix +justConstr :: Constr justConstr = mkConstr maybeDataType "Just" [] Prefix + +maybeDataType :: DataType maybeDataType = mkDataType "Prelude.Maybe" [nothingConstr,justConstr] instance Data a => Data (Maybe a) where - gfoldl f z Nothing = z Nothing + gfoldl _ z Nothing = z Nothing gfoldl f z (Just x) = z Just `f` x toConstr Nothing = nothingConstr toConstr (Just _) = justConstr @@ -312,20 +324,24 @@ instance Data a => Data (Maybe a) where ------------------------------------------------------------------------------ - +ltConstr :: Constr ltConstr = mkConstr orderingDataType "LT" [] Prefix +eqConstr :: Constr eqConstr = mkConstr orderingDataType "EQ" [] Prefix +gtConstr :: Constr gtConstr = mkConstr orderingDataType "GT" [] Prefix + +orderingDataType :: DataType orderingDataType = mkDataType "Prelude.Ordering" [ltConstr,eqConstr,gtConstr] instance Data Ordering where - gfoldl f z LT = z LT - gfoldl f z EQ = z EQ - gfoldl f z GT = z GT + gfoldl _ z LT = z LT + gfoldl _ z EQ = z EQ + gfoldl _ z GT = z GT toConstr LT = ltConstr toConstr EQ = eqConstr toConstr GT = gtConstr - gunfold k z c = case constrIndex c of + gunfold _ z c = case constrIndex c of 1 -> z LT 2 -> z EQ 3 -> z GT @@ -335,9 +351,13 @@ instance Data Ordering where ------------------------------------------------------------------------------ - +leftConstr :: Constr leftConstr = mkConstr eitherDataType "Left" [] Prefix + +rightConstr :: Constr rightConstr = mkConstr eitherDataType "Right" [] Prefix + +eitherDataType :: DataType eitherDataType = mkDataType "Prelude.Either" [leftConstr,rightConstr] instance (Data a, Data b) => Data (Either a b) where @@ -369,26 +389,30 @@ instance (Data a, Data b) => Data (a -> b) where ------------------------------------------------------------------------------ - +tuple0Constr :: Constr tuple0Constr = mkConstr tuple0DataType "()" [] Prefix + +tuple0DataType :: DataType tuple0DataType = mkDataType "Prelude.()" [tuple0Constr] instance Data () where toConstr () = tuple0Constr - gunfold k z c | constrIndex c == 1 = z () + gunfold _ z c | constrIndex c == 1 = z () gunfold _ _ _ = error "gunfold" dataTypeOf _ = tuple0DataType ------------------------------------------------------------------------------ - +tuple2Constr :: Constr tuple2Constr = mkConstr tuple2DataType "(,)" [] Infix + +tuple2DataType :: DataType tuple2DataType = mkDataType "Prelude.(,)" [tuple2Constr] instance (Data a, Data b) => Data (a,b) where gfoldl f z (a,b) = z (,) `f` a `f` b - toConstr (a,b) = tuple2Constr + toConstr (_,_) = tuple2Constr gunfold k z c | constrIndex c == 1 = k (k (z (,))) gunfold _ _ _ = error "gunfold" dataTypeOf _ = tuple2DataType @@ -397,13 +421,15 @@ instance (Data a, Data b) => Data (a,b) where ------------------------------------------------------------------------------ - +tuple3Constr :: Constr tuple3Constr = mkConstr tuple3DataType "(,,)" [] Infix + +tuple3DataType :: DataType tuple3DataType = mkDataType "Prelude.(,)" [tuple3Constr] instance (Data a, Data b, Data c) => Data (a,b,c) where gfoldl f z (a,b,c) = z (,,) `f` a `f` b `f` c - toConstr (a,b,c) = tuple3Constr + toConstr (_,_,_) = tuple3Constr gunfold k z c | constrIndex c == 1 = k (k (k (z (,,)))) gunfold _ _ _ = error "gunfold" dataTypeOf _ = tuple3DataType @@ -411,14 +437,16 @@ instance (Data a, Data b, Data c) => Data (a,b,c) where ------------------------------------------------------------------------------ - +tuple4Constr :: Constr tuple4Constr = mkConstr tuple4DataType "(,,,)" [] Infix + +tuple4DataType :: DataType tuple4DataType = mkDataType "Prelude.(,,,)" [tuple4Constr] instance (Data a, Data b, Data c, Data d) => Data (a,b,c,d) where gfoldl f z (a,b,c,d) = z (,,,) `f` a `f` b `f` c `f` d - toConstr (a,b,c,d) = tuple4Constr + toConstr (_,_,_,_) = tuple4Constr gunfold k z c = case constrIndex c of 1 -> k (k (k (k (z (,,,))))) _ -> error "gunfold" @@ -427,14 +455,16 @@ instance (Data a, Data b, Data c, Data d) ------------------------------------------------------------------------------ - +tuple5Constr :: Constr tuple5Constr = mkConstr tuple5DataType "(,,,,)" [] Infix + +tuple5DataType :: DataType tuple5DataType = mkDataType "Prelude.(,,,,)" [tuple5Constr] instance (Data a, Data b, Data c, Data d, Data e) => Data (a,b,c,d,e) where gfoldl f z (a,b,c,d,e) = z (,,,,) `f` a `f` b `f` c `f` d `f` e - toConstr (a,b,c,d,e) = tuple5Constr + toConstr (_,_,_,_,_) = tuple5Constr gunfold k z c = case constrIndex c of 1 -> k (k (k (k (k (z (,,,,)))))) _ -> error "gunfold" @@ -443,14 +473,16 @@ instance (Data a, Data b, Data c, Data d, Data e) ------------------------------------------------------------------------------ - +tuple6Constr :: Constr tuple6Constr = mkConstr tuple6DataType "(,,,,,)" [] Infix + +tuple6DataType :: DataType tuple6DataType = mkDataType "Prelude.(,,,,,)" [tuple6Constr] instance (Data a, Data b, Data c, Data d, Data e, Data f) => Data (a,b,c,d,e,f) where gfoldl f z (a,b,c,d,e,f') = z (,,,,,) `f` a `f` b `f` c `f` d `f` e `f` f' - toConstr (a,b,c,d,e,f) = tuple6Constr + toConstr (_,_,_,_,_,_) = tuple6Constr gunfold k z c = case constrIndex c of 1 -> k (k (k (k (k (k (z (,,,,,))))))) _ -> error "gunfold" @@ -459,15 +491,17 @@ instance (Data a, Data b, Data c, Data d, Data e, Data f) ------------------------------------------------------------------------------ - +tuple7Constr :: Constr tuple7Constr = mkConstr tuple7DataType "(,,,,,,)" [] Infix + +tuple7DataType :: DataType tuple7DataType = mkDataType "Prelude.(,,,,,,)" [tuple7Constr] instance (Data a, Data b, Data c, Data d, Data e, Data f, Data g) => Data (a,b,c,d,e,f,g) where gfoldl f z (a,b,c,d,e,f',g) = z (,,,,,,) `f` a `f` b `f` c `f` d `f` e `f` f' `f` g - toConstr (a,b,c,d,e,f,g) = tuple7Constr + toConstr (_,_,_,_,_,_,_) = tuple7Constr gunfold k z c = case constrIndex c of 1 -> k (k (k (k (k (k (k (z (,,,,,,)))))))) _ -> error "gunfold" diff --git a/Data/Generics/Twins.hs b/Data/Generics/Twins.hs index 4045c2e..e66be72 100644 --- a/Data/Generics/Twins.hs +++ b/Data/Generics/Twins.hs @@ -76,11 +76,11 @@ Applying the same scheme we obtain an accumulating gfoldl. -- | gfoldl with accumulation gfoldlAccum :: Data d - => (forall d r. Data d => a -> c (d -> r) -> d -> (a, c r)) + => (forall e r. Data e => a -> c (e -> r) -> e -> (a, c r)) -> (forall g. a -> g -> (a, c g)) -> a -> d -> (a, c d) -gfoldlAccum k z a d = unA (gfoldl k' z' d) a +gfoldlAccum k z a0 d = unA (gfoldl k' z' d) a0 where k' c y = A (\a -> let (a', c') = unA c a in k a' c' y) z' f = A (\a -> z a f) @@ -92,10 +92,10 @@ newtype A a c d = A { unA :: a -> (a, c d) } -- | gmapT with accumulation gmapAccumT :: Data d - => (forall d. Data d => a -> d -> (a,d)) + => (forall e. Data e => a -> e -> (a,e)) -> a -> d -> (a, d) -gmapAccumT f a d = let (a',d') = gfoldlAccum k z a d - in (a',unID d') +gmapAccumT f a0 d0 = let (a1, d1) = gfoldlAccum k z a0 d0 + in (a1, unID d1) where k a (ID c) d = let (a',d') = f a d in (a', ID (c d')) @@ -104,7 +104,7 @@ gmapAccumT f a d = let (a',d') = gfoldlAccum k z a d -- | gmapM with accumulation gmapAccumM :: (Data d, Monad m) - => (forall d. Data d => a -> d -> (a, m d)) + => (forall e. Data e => a -> e -> (a, m e)) -> a -> d -> (a, m d) gmapAccumM f = gfoldlAccum k z where @@ -117,24 +117,24 @@ gmapAccumM f = gfoldlAccum k z gmapAccumQl :: Data d => (r -> r' -> r) -> r - -> (forall d. Data d => a -> d -> (a,r')) + -> (forall e. Data e => a -> e -> (a,r')) -> a -> d -> (a, r) -gmapAccumQl o r f a d = let (a',r) = gfoldlAccum k z a d - in (a',unCONST r) +gmapAccumQl o r0 f a0 d0 = let (a1, r1) = gfoldlAccum k z a0 d0 + in (a1, unCONST r1) where - k a (CONST c) d = let (a',r') = f a d - in (a', CONST (c `o` r')) - z a _ = (a, CONST r) + k a (CONST c) d = let (a', r) = f a d + in (a', CONST (c `o` r)) + z a _ = (a, CONST r0) -- | gmapQr with accumulation gmapAccumQr :: Data d => (r' -> r -> r) -> r - -> (forall d. Data d => a -> d -> (a,r')) + -> (forall e. Data e => a -> e -> (a,r')) -> a -> d -> (a, r) -gmapAccumQr o r f a d = let (a',l) = gfoldlAccum k z a d - in (a',unQr l r) +gmapAccumQr o r0 f a0 d0 = let (a1, l) = gfoldlAccum k z a0 d0 + in (a1, unQr l r0) where k a (Qr c) d = let (a',r') = f a d in (a', Qr (\r -> c (r' `o` r))) @@ -143,7 +143,7 @@ gmapAccumQr o r f a d = let (a',l) = gfoldlAccum k z a d -- | gmapQ with accumulation gmapAccumQ :: Data d - => (forall d. Data d => a -> d -> (a,q)) + => (forall e. Data e => a -> e -> (a,q)) -> a -> d -> (a, [q]) gmapAccumQ f = gmapAccumQr (:) [] f @@ -232,7 +232,7 @@ couples of immediate subterms from the two given input terms.) -} -geq x y = geq' x y +geq x0 y0 = geq' x0 y0 where geq' :: GenericQ (GenericQ Bool) geq' x y = (toConstr x == toConstr y)