summaryrefslogtreecommitdiff
path: root/compiler/utils/Pair.hs
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2019-06-08 20:48:07 +0200
committerKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2019-06-09 14:35:50 +0200
commit4c44e323e8ac0e28e87e93ab53cbf7eb21ac9c25 (patch)
treeb0991218e9cac8f76224df017856045c71d779e4 /compiler/utils/Pair.hs
parent8754002973dcde8709458044e541ddc8f4fcf6bb (diff)
downloadhaskell-wip/derive-functor.tar.gz
Use DeriveFunctor throughout the codebase (#15654)wip/derive-functor
Diffstat (limited to 'compiler/utils/Pair.hs')
-rw-r--r--compiler/utils/Pair.hs4
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