diff options
Diffstat (limited to 'compiler/utils/Pair.hs')
-rw-r--r-- | compiler/utils/Pair.hs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/utils/Pair.hs b/compiler/utils/Pair.hs index 036dab062d..e9313f89b2 100644 --- a/compiler/utils/Pair.hs +++ b/compiler/utils/Pair.hs @@ -4,6 +4,7 @@ Traversable instances. -} {-# LANGUAGE CPP #-} +{-# LANGUAGE DeriveFunctor #-} module Pair ( Pair(..), unPair, toPair, swap, pLiftFst, pLiftSnd ) where @@ -15,14 +16,13 @@ import Outputable import qualified Data.Semigroup as Semi data Pair a = Pair { pFst :: a, pSnd :: a } + deriving (Functor) -- Note that Pair is a *unary* type constructor -- whereas (,) is binary -- The important thing about Pair is that it has a *homogeneous* -- Functor instance, so you can easily apply the same function -- to both components -instance Functor Pair where - fmap f (Pair x y) = Pair (f x) (f y) instance Applicative Pair where pure x = Pair x x |