summaryrefslogtreecommitdiff
path: root/compiler/typecheck
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2019-06-08 20:48:07 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-06-12 07:37:12 -0400
commit1219f8e8a3d1b58263bea76822322b746a632778 (patch)
treebd93bdf1e09cd26a7c6104ba37c6734a74e8a7bc /compiler/typecheck
parent217e6db4af6752b13c586d4e8925a4a9a2f47245 (diff)
downloadhaskell-1219f8e8a3d1b58263bea76822322b746a632778.tar.gz
Use DeriveFunctor throughout the codebase (#15654)
Diffstat (limited to 'compiler/typecheck')
-rw-r--r--compiler/typecheck/TcCanonical.hs6
-rw-r--r--compiler/typecheck/TcFlatten.hs6
-rw-r--r--compiler/typecheck/TcRnTypes.hs9
-rw-r--r--compiler/typecheck/TcSMonad.hs7
-rw-r--r--compiler/typecheck/TcTyDecls.hs9
-rw-r--r--compiler/typecheck/TcUnify.hs7
6 files changed, 15 insertions, 29 deletions
diff --git a/compiler/typecheck/TcCanonical.hs b/compiler/typecheck/TcCanonical.hs
index 9440d5ff0a..e0c87e0f70 100644
--- a/compiler/typecheck/TcCanonical.hs
+++ b/compiler/typecheck/TcCanonical.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE CPP #-}
+{-# LANGUAGE DeriveFunctor #-}
module TcCanonical(
canonicalize,
@@ -2188,10 +2189,7 @@ data StopOrContinue a
| Stop CtEvidence -- The (rewritten) constraint was solved
SDoc -- Tells how it was solved
-- Any new sub-goals have been put on the work list
-
-instance Functor StopOrContinue where
- fmap f (ContinueWith x) = ContinueWith (f x)
- fmap _ (Stop ev s) = Stop ev s
+ deriving (Functor)
instance Outputable a => Outputable (StopOrContinue a) where
ppr (Stop ev s) = text "Stop" <> parens s <+> ppr ev
diff --git a/compiler/typecheck/TcFlatten.hs b/compiler/typecheck/TcFlatten.hs
index 39a33f3fd7..2bb3d1c0e8 100644
--- a/compiler/typecheck/TcFlatten.hs
+++ b/compiler/typecheck/TcFlatten.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE CPP, ViewPatterns, BangPatterns #-}
+{-# LANGUAGE CPP, DeriveFunctor, ViewPatterns, BangPatterns #-}
module TcFlatten(
FlattenMode(..),
@@ -485,15 +485,13 @@ eqFlattenMode _ _ = False
-- See Note [The flattening work list].
newtype FlatM a
= FlatM { runFlatM :: FlattenEnv -> TcS a }
+ deriving (Functor)
instance Monad FlatM where
m >>= k = FlatM $ \env ->
do { a <- runFlatM m env
; runFlatM (k a) env }
-instance Functor FlatM where
- fmap = liftM
-
instance Applicative FlatM where
pure x = FlatM $ const (pure x)
(<*>) = ap
diff --git a/compiler/typecheck/TcRnTypes.hs b/compiler/typecheck/TcRnTypes.hs
index bf98e0c2b1..221d9cea8c 100644
--- a/compiler/typecheck/TcRnTypes.hs
+++ b/compiler/typecheck/TcRnTypes.hs
@@ -16,7 +16,7 @@ For state that is global and should be returned at the end (e.g not part
of the stack mechanism), you should use a TcRef (= IORef) to store them.
-}
-{-# LANGUAGE CPP, ExistentialQuantification, GeneralizedNewtypeDeriving,
+{-# LANGUAGE CPP, DeriveFunctor, ExistentialQuantification, GeneralizedNewtypeDeriving,
ViewPatterns #-}
module TcRnTypes(
@@ -195,7 +195,7 @@ import Util
import PrelNames ( isUnboundName )
import CostCentreState
-import Control.Monad (ap, liftM, msum)
+import Control.Monad (ap, msum)
import qualified Control.Monad.Fail as MonadFail
import Data.Set ( Set )
import qualified Data.Set as S
@@ -3832,10 +3832,7 @@ type TcPluginSolver = [Ct] -- given
-> [Ct] -- wanted
-> TcPluginM TcPluginResult
-newtype TcPluginM a = TcPluginM (EvBindsVar -> TcM a)
-
-instance Functor TcPluginM where
- fmap = liftM
+newtype TcPluginM a = TcPluginM (EvBindsVar -> TcM a) deriving (Functor)
instance Applicative TcPluginM where
pure x = TcPluginM (const $ pure x)
diff --git a/compiler/typecheck/TcSMonad.hs b/compiler/typecheck/TcSMonad.hs
index 8d98a17149..68496dfca6 100644
--- a/compiler/typecheck/TcSMonad.hs
+++ b/compiler/typecheck/TcSMonad.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE CPP, TypeFamilies #-}
+{-# LANGUAGE CPP, DeriveFunctor, TypeFamilies #-}
-- Type definitions for the constraint solver
module TcSMonad (
@@ -2601,10 +2601,7 @@ data TcSEnv
}
---------------
-newtype TcS a = TcS { unTcS :: TcSEnv -> TcM a }
-
-instance Functor TcS where
- fmap f m = TcS $ fmap f . unTcS m
+newtype TcS a = TcS { unTcS :: TcSEnv -> TcM a } deriving (Functor)
instance Applicative TcS where
pure x = TcS (\_ -> return x)
diff --git a/compiler/typecheck/TcTyDecls.hs b/compiler/typecheck/TcTyDecls.hs
index 205771b2db..7a68fe1144 100644
--- a/compiler/typecheck/TcTyDecls.hs
+++ b/compiler/typecheck/TcTyDecls.hs
@@ -10,6 +10,7 @@ files for imported data types.
-}
{-# LANGUAGE CPP #-}
+{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
@@ -149,12 +150,10 @@ synonymTyConsOfType ty
-- a failure message reporting that a cycle was found.
newtype SynCycleM a = SynCycleM {
runSynCycleM :: SynCycleState -> Either (SrcSpan, SDoc) (a, SynCycleState) }
+ deriving (Functor)
type SynCycleState = NameSet
-instance Functor SynCycleM where
- fmap = liftM
-
instance Applicative SynCycleM where
pure x = SynCycleM $ \state -> Right (x, state)
(<*>) = ap
@@ -677,9 +676,7 @@ newtype RoleM a = RM { unRM :: Maybe Name -- of the tycon
-> Int -- size of VarPositions
-> RoleInferenceState
-> (a, RoleInferenceState) }
-
-instance Functor RoleM where
- fmap = liftM
+ deriving (Functor)
instance Applicative RoleM where
pure x = RM $ \_ _ _ state -> (x, state)
diff --git a/compiler/typecheck/TcUnify.hs b/compiler/typecheck/TcUnify.hs
index cbf98d888c..078ebecd54 100644
--- a/compiler/typecheck/TcUnify.hs
+++ b/compiler/typecheck/TcUnify.hs
@@ -6,7 +6,8 @@
Type subsumption and unification
-}
-{-# LANGUAGE CPP, MultiWayIf, TupleSections, ScopedTypeVariables #-}
+{-# LANGUAGE CPP, DeriveFunctor, MultiWayIf, TupleSections,
+ ScopedTypeVariables #-}
module TcUnify (
-- Full-blown subsumption
@@ -2119,9 +2120,7 @@ data MetaTyVarUpdateResult a
= MTVU_OK a
| MTVU_Bad -- Forall, predicate, or type family
| MTVU_Occurs
-
-instance Functor MetaTyVarUpdateResult where
- fmap = liftM
+ deriving (Functor)
instance Applicative MetaTyVarUpdateResult where
pure = MTVU_OK