@@ -79,7 +79,6 @@ updateHsModule hsm =
7979 astTraversal :: Traversal' (LHsDecl GhcPs) (HsType GhcPs)
8080 astTraversal = updateHsmodDecl
8181 . updateHsDecl
82− . updateSig
8382 . updateLHsSigWsType
8483 . updateLHsSigType
8584 . updateLHsType
@@ -88,10 +87,56 @@ updateHsModule hsm =
8887updateHsmodDecl :: Traversal' (LHsDecl GhcPs) (HsDecl GhcPs)
8988updateHsmodDecl = traverse
9089
91−updateHsDecl :: Traversal' (HsDecl GhcPs) (Sig GhcPs)
92−updateHsDecl f (SigD xSig s) = SigD xSig <$> f s
90+updateHsDecl :: Traversal' (HsDecl GhcPs) (LHsSigWcType GhcPs)
91+updateHsDecl f (SigD xSig s) = SigD xSig <$> updateSig f s
92+updateHsDecl f (ValD xVal hsBind) = ValD xVal <$> updateHsBind f hsBind
9393updateHsDecl _ sig = pure sig
9494
95+updateHsBind :: Traversal' (HsBind GhcPs) (LHsSigWcType GhcPs)
96+updateHsBind f bind@FunBind {} = (\x -> bind {fun_matches = x}) <$> updateMatchGroup f (fun_matches bind)
97+updateHsBind _ bind = pure bind
98+
99+updateMatchGroup :: Traversal' (MatchGroup GhcPs (LHsExpr GhcPs)) (LHsSigWcType GhcPs)
100+updateMatchGroup f mg@MG {} = (\x -> mg {mg_alts = x}) <$> updateLLMatch f (mg_alts mg)
101+#if __GLASGOW_HASKELL__ < 900
102+updateMatchGroup _ mg = pure mg
103+#endif
104+
105+updateLocated :: Functor f => (a -> b -> f c) -> a -> Located b -> f (Located c)
106+updateLocated f g (L l e) = L l <$> f g e
107+
108+updateLLMatch :: Traversal' (Located [LMatch GhcPs (LHsExpr GhcPs)]) (LHsSigWcType GhcPs)
109+updateLLMatch = updateLocated updateLMatches
110+
111+updateLMatches :: Traversal' [LMatch GhcPs (LHsExpr GhcPs)] (LHsSigWcType GhcPs)
112+updateLMatches f = traverse (updateLocated updateMatch f)
113+
114+updateMatch :: Traversal' (Match GhcPs (LHsExpr GhcPs)) (LHsSigWcType GhcPs)
115+updateMatch f m@Match {} = (\x -> m {m_grhss = x}) <$> updateGrhss f (m_grhss m)
116+#if __GLASGOW_HASKELL__ < 900
117+updateMatch _ m = pure m
118+#endif
119+
120+updateGrhss :: Traversal' (GRHSs GhcPs (LHsExpr GhcPs)) (LHsSigWcType GhcPs)
121+updateGrhss f grhss@GRHSs {} = (\x -> grhss {grhssLocalBinds = x}) <$> updateLHsLocalBinds f (grhssLocalBinds grhss)
122+#if __GLASGOW_HASKELL__ < 900
123+updateGrhss _ grhss = pure grhss
124+#endif
125+
126+updateLHsLocalBinds :: Traversal' (LHsLocalBinds GhcPs) (LHsSigWcType GhcPs)
127+updateLHsLocalBinds = updateLocated updateLocalBinds
128+
129+updateLocalBinds :: Traversal' (HsLocalBinds GhcPs) (LHsSigWcType GhcPs)
130+updateLocalBinds f (HsValBinds xHsValBinds hsValBindsLR) = HsValBinds xHsValBinds <$> updateHsValBindsLR f hsValBindsLR
131+updateLocalBinds _ hsValBinds = pure hsValBinds
132+
133+updateHsValBindsLR :: Traversal' (HsValBindsLR GhcPs GhcPs) (LHsSigWcType GhcPs)
134+updateHsValBindsLR f (ValBinds xValBinds lHsBindsLR lSigs) = ValBinds xValBinds lHsBindsLR <$> updateLSigs f lSigs
135+updateHsValBindsLR _ valBinds = pure valBinds
136+
137+updateLSigs :: Traversal' [LSig GhcPs] (LHsSigWcType GhcPs)
138+updateLSigs f = traverse (updateLocated updateSig f)
139+
95140updateSig :: Traversal' (Sig GhcPs) (LHsSigWcType GhcPs)
96141updateSig f (TypeSig xSig ls t) = TypeSig xSig ls <$> f t
97142updateSig _ sig = pure sig
@@ -123,7 +168,7 @@ updateHsType ty@HsAppTy {} =
123168 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)
124169updateHsType ty@HsFunTy {} =
125170 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)
126−updateHsType ty@HsListTy {} =
171+updateHsType ty@HsListTy {} =
127172 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)
128173updateHsType ty@HsTupleTy {} =
129174 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)