@@ -56,6 +56,8 @@ import Control.DeepSeq (NFData(..))
5656import Control.DeepSeq (NFData1 (.. ), NFData2 (.. ))
5757#endif
5858
59+ import Data.Coerce (coerce )
60+
5961-- * Basic functors
6062
6163-- | The constant type functor.
@@ -274,105 +276,98 @@ unComp (Comp x) = x
274276
275277-- * Mapping functions
276278
277- -- Implementation note:
278- --
279- -- All of these functions are just type specializations of
280- -- 'coerce'. However, we currently still support GHC 7.6
281- -- which does not support 'coerce', so we write them
282- -- explicitly.
283-
284279-- | Lift the given function.
285280--
286281-- @since 0.2.5.0
287282--
288283mapII :: (a -> b ) -> I a -> I b
289- mapII = \ f ( I a) -> I (f a)
284+ mapII = coerce
290285{-# INLINE mapII #-}
291286
292287-- | Lift the given function.
293288--
294289-- @since 0.2.5.0
295290--
296291mapIK :: (a -> b ) -> I a -> K b c
297- mapIK = \ f ( I a) -> K (f a)
292+ mapIK = coerce
298293{-# INLINE mapIK #-}
299294
300295-- | Lift the given function.
301296--
302297-- @since 0.2.5.0
303298--
304299mapKI :: (a -> b ) -> K a c -> I b
305- mapKI = \ f ( K a) -> I (f a)
300+ mapKI = coerce
306301{-# INLINE mapKI #-}
307302
308303-- | Lift the given function.
309304--
310305-- @since 0.2.5.0
311306--
312307mapKK :: (a -> b ) -> K a c -> K b d
313- mapKK = \ f ( K a) -> K (f a)
308+ mapKK = coerce
314309{-# INLINE mapKK #-}
315310
316311-- | Lift the given function.
317312--
318313-- @since 0.2.5.0
319314--
320315mapIII :: (a -> b -> c ) -> I a -> I b -> I c
321- mapIII = \ f ( I a) ( I b) -> I (f a b)
316+ mapIII = coerce
322317{-# INLINE mapIII #-}
323318
324319-- | Lift the given function.
325320--
326321-- @since 0.2.5.0
327322--
328323mapIIK :: (a -> b -> c ) -> I a -> I b -> K c d
329- mapIIK = \ f ( I a) ( I b) -> K (f a b)
324+ mapIIK = coerce
330325{-# INLINE mapIIK #-}
331326
332327-- | Lift the given function.
333328--
334329-- @since 0.2.5.0
335330--
336331mapIKI :: (a -> b -> c ) -> I a -> K b d -> I c
337- mapIKI = \ f ( I a) ( K b) -> I (f a b)
332+ mapIKI = coerce
338333{-# INLINE mapIKI #-}
339334
340335-- | Lift the given function.
341336--
342337-- @since 0.2.5.0
343338--
344339mapIKK :: (a -> b -> c ) -> I a -> K b d -> K c e
345- mapIKK = \ f ( I a) ( K b) -> K (f a b)
340+ mapIKK = coerce
346341{-# INLINE mapIKK #-}
347342
348343-- | Lift the given function.
349344--
350345-- @since 0.2.5.0
351346--
352347mapKII :: (a -> b -> c ) -> K a d -> I b -> I c
353- mapKII = \ f ( K a) ( I b) -> I (f a b)
348+ mapKII = coerce
354349{-# INLINE mapKII #-}
355350
356351-- | Lift the given function.
357352--
358353-- @since 0.2.5.0
359354--
360355mapKIK :: (a -> b -> c ) -> K a d -> I b -> K c e
361- mapKIK = \ f ( K a) ( I b) -> K (f a b)
356+ mapKIK = coerce
362357{-# INLINE mapKIK #-}
363358
364359-- | Lift the given function.
365360--
366361-- @since 0.2.5.0
367362--
368363mapKKI :: (a -> b -> c ) -> K a d -> K b e -> I c
369- mapKKI = \ f ( K a) ( K b) -> I (f a b)
364+ mapKKI = coerce
370365{-# INLINE mapKKI #-}
371366
372367-- | Lift the given function.
373368--
374369-- @since 0.2.5.0
375370--
376371mapKKK :: (a -> b -> c ) -> K a d -> K b e -> K c f
377- mapKKK = \ f ( K a) ( K b) -> K (f a b)
372+ mapKKK = coerce
378373{-# INLINE mapKKK #-}
0 commit comments