Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8a35111

Browse files
committed
Use a local version of Identity on old versions of base
1 parent c7f8361 commit 8a35111

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

‎Data/IntMap/Merge/Internal.hs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
{-# LANGUAGE BangPatterns #-}
1+
{-# LANGUAGE CPP, BangPatterns #-}
2+
3+
#include "containers.h"
24

35
-----------------------------------------------------------------------------
46
-- |
@@ -30,10 +32,39 @@
3032
module Data.IntMap.Merge.Internal where
3133

3234
import Prelude hiding (min, max)
33-
import Data.Functor.Identity (Identity, runIdentity)
3435

3536
import Data.IntMap.Internal
3637

38+
#if MIN_VERSION_base (4,8,0)
39+
import Data.Functor.Identity (Identity, runIdentity)
40+
#else
41+
import Control.Applicative (Applicative(..))
42+
#if __GLASGOW_HASKELL__ >= 708
43+
import Data.Coerce
44+
#endif
45+
#endif
46+
47+
48+
#if !MIN_VERSION_base (4,8,0)
49+
-- | The identity type.
50+
newtype Identity a = Identity { runIdentity :: a }
51+
52+
#if __GLASGOW_HASKELL__ >= 708
53+
instance Functor Identity where
54+
fmap = coerce
55+
instance Applicative Identity where
56+
(<*>) = coerce
57+
pure = Identity
58+
#else
59+
instance Functor Identity where
60+
fmap f (Identity a) = Identity (f a)
61+
instance Applicative Identity where
62+
Identity f <*> Identity x = Identity (f x)
63+
pure = Identity
64+
#endif
65+
#endif
66+
67+
3768
-- | A tactic for dealing with keys present in one map but not the other in
3869
-- 'merge' or 'mergeA'.
3970
--

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /