Skip to content

Commit de9ba5c

Browse files
committed
fix old compiler eta reduce
1 parent a9a71d5 commit de9ba5c

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

src/Data/IntMap/NonEmpty/Internal.hs

+13
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ instance NFData a => NFData (NEIntMap a) where
185185
-- Copyright : (c) Daan Leijen 2002
186186
-- (c) Andriy Palamarchuk 2008
187187
-- (c) wren romano 2016
188+
#if MIN_VERSION_base(4,16,0)
188189
instance Data a => Data (NEIntMap a) where
189190
gfoldl f z im = z fromList `f` toList im
190191
toConstr _ = fromListConstr
@@ -193,6 +194,18 @@ instance Data a => Data (NEIntMap a) where
193194
_ -> error "gunfold"
194195
dataTypeOf _ = intMapDataType
195196
dataCast1 = gcast1
197+
#else
198+
#ifndef __HLINT__
199+
instance Data a => Data (NEIntMap a) where
200+
gfoldl f z im = z fromList `f` toList im
201+
toConstr _ = fromListConstr
202+
gunfold k z c = case constrIndex c of
203+
1 -> k (z fromList)
204+
_ -> error "gunfold"
205+
dataTypeOf _ = intMapDataType
206+
dataCast1 f = gcast1 f
207+
#endif
208+
#endif
196209

197210
fromListConstr :: Constr
198211
fromListConstr = mkConstr intMapDataType "fromList" [] Prefix

src/Data/Map/NonEmpty/Internal.hs

+13
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ instance (NFData k, NFData a) => NFData (NEMap k a) where
185185
--
186186
-- Copyright : (c) Daan Leijen 2002
187187
-- (c) Andriy Palamarchuk 2008
188+
#if MIN_VERSION_base(4,16,0)
188189
instance (Data k, Data a, Ord k) => Data (NEMap k a) where
189190
gfoldl f z m = z fromList `f` toList m
190191
toConstr _ = fromListConstr
@@ -193,6 +194,18 @@ instance (Data k, Data a, Ord k) => Data (NEMap k a) where
193194
_ -> error "gunfold"
194195
dataTypeOf _ = mapDataType
195196
dataCast2 = gcast2
197+
#else
198+
#ifndef __HLINT__
199+
instance (Data k, Data a, Ord k) => Data (NEMap k a) where
200+
gfoldl f z m = z fromList `f` toList m
201+
toConstr _ = fromListConstr
202+
gunfold k z c = case constrIndex c of
203+
1 -> k (z fromList)
204+
_ -> error "gunfold"
205+
dataTypeOf _ = mapDataType
206+
dataCast2 f = gcast2 f
207+
#endif
208+
#endif
196209

197210
fromListConstr :: Constr
198211
fromListConstr = mkConstr mapDataType "fromList" [] Prefix

src/Data/Sequence/NonEmpty/Internal.hs

+11
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,23 @@ instance Eq1 NESeq where
190190
instance Ord1 NESeq where
191191
liftCompare cmp xs ys = liftCompare cmp (toNonEmpty xs) (toNonEmpty ys)
192192

193+
#if MIN_VERSION_base(4,16,0)
193194
instance Data a => Data (NESeq a) where
194195
gfoldl f z (x :<|| xs) = z (:<||) `f` x `f` xs
195196
gunfold k z _ = k (k (z (:<||)))
196197
toConstr _ = consConstr
197198
dataTypeOf _ = seqDataType
198199
dataCast1 = gcast1
200+
#else
201+
#ifndef __HLINT__
202+
instance Data a => Data (NESeq a) where
203+
gfoldl f z (x :<|| xs) = z (:<||) `f` x `f` xs
204+
gunfold k z _ = k (k (z (:<||)))
205+
toConstr _ = consConstr
206+
dataTypeOf _ = seqDataType
207+
dataCast1 f = gcast1 f
208+
#endif
209+
#endif
199210

200211
consConstr :: Constr
201212
consConstr = mkConstr seqDataType ":<||" [] Infix

src/Data/Set/NonEmpty/Internal.hs

+13
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ instance NFData a => NFData (NESet a) where
151151
-- Data instance code from Data.Set.Internal
152152
--
153153
-- Copyright : (c) Daan Leijen 2002
154+
#if MIN_VERSION_base(4,16,0)
154155
instance (Data a, Ord a) => Data (NESet a) where
155156
gfoldl f z set = z fromList `f` toList set
156157
toConstr _ = fromListConstr
@@ -159,6 +160,18 @@ instance (Data a, Ord a) => Data (NESet a) where
159160
_ -> error "gunfold"
160161
dataTypeOf _ = setDataType
161162
dataCast1 = gcast1
163+
#else
164+
#ifndef __HLINT__
165+
instance (Data a, Ord a) => Data (NESet a) where
166+
gfoldl f z set = z fromList `f` toList set
167+
toConstr _ = fromListConstr
168+
gunfold k z c = case constrIndex c of
169+
1 -> k (z fromList)
170+
_ -> error "gunfold"
171+
dataTypeOf _ = setDataType
172+
dataCast1 f = gcast1 f
173+
#endif
174+
#endif
162175

163176
fromListConstr :: Constr
164177
fromListConstr = mkConstr setDataType "fromList" [] Prefix

0 commit comments

Comments
 (0)