|
1 | | -{-# LANGUAGE BangPatterns #-} |
| 1 | +{-# LANGUAGE CPP, BangPatterns #-} |
| 2 | + |
| 3 | +#include "containers.h" |
2 | 4 |
|
3 | 5 | -----------------------------------------------------------------------------
|
4 | 6 | -- |
|
|
30 | 32 | module Data.IntMap.Merge.Internal where
|
31 | 33 |
|
32 | 34 | import Prelude hiding (min, max)
|
33 | | -import Data.Functor.Identity (Identity, runIdentity) |
34 | 35 |
|
35 | 36 | import Data.IntMap.Internal
|
36 | 37 |
|
| 38 | +#if MIN_VERSION_base (4,8,0) |
| 39 | +import Data.Functor.Identity (Identity, runIdentity) |
| 40 | +#else |
| 41 | +import Control.Applicative (Applicative(..)) |
| 42 | +#endif |
| 43 | + |
| 44 | +#if __GLASGOW_HASKELL__ >= 708 |
| 45 | +import Data.Coerce |
| 46 | +#endif |
| 47 | + |
| 48 | + |
| 49 | +#if MIN_Version_base (4,8,0) |
| 50 | +-- | The identity type. |
| 51 | +newtype Identity a = Identity { runIdentity :: a } |
| 52 | + |
| 53 | +#if __GLASGOW_HASKELL__ >= 708 |
| 54 | +instance Functor Identity where |
| 55 | + fmap = coerce |
| 56 | +instance Applicative Identity where |
| 57 | + (<*>) = coerce |
| 58 | + pure = Identity |
| 59 | +#else |
| 60 | +instance Functor Identity where |
| 61 | + fmap f (Identity a) = Identity (f a) |
| 62 | +instance Applicative Identity where |
| 63 | + Identity f <*> Identity x = Identity (f x) |
| 64 | + pure = Identity |
| 65 | +#endif |
| 66 | +#endif |
| 67 | + |
| 68 | + |
37 | 69 | -- | A tactic for dealing with keys present in one map but not the other in
|
38 | 70 | -- 'merge' or 'mergeA'.
|
39 | 71 | --
|
|
0 commit comments