diff options
author | Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> | 2019-06-08 20:48:07 +0200 |
---|---|---|
committer | Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> | 2019-06-09 14:35:50 +0200 |
commit | 4c44e323e8ac0e28e87e93ab53cbf7eb21ac9c25 (patch) | |
tree | b0991218e9cac8f76224df017856045c71d779e4 /compiler/utils/Pair.hs | |
parent | 8754002973dcde8709458044e541ddc8f4fcf6bb (diff) | |
download | haskell-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.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 |