@@ -79,7 +79,6 @@ updateHsModule hsm =
79 astTraversal :: Traversal' (LHsDecl GhcPs) (HsType GhcPs)
79 astTraversal :: Traversal' (LHsDecl GhcPs) (HsType GhcPs)
80 astTraversal = updateHsmodDecl
80 astTraversal = updateHsmodDecl
81 . updateHsDecl
81 . updateHsDecl
83 . updateLHsSigWsType
82 . updateLHsSigWsType
84 . updateLHsSigType
83 . updateLHsSigType
85 . updateLHsType
84 . updateLHsType
@@ -88,10 +87,56 @@ updateHsModule hsm =
88updateHsmodDecl :: Traversal' (LHsDecl GhcPs) (HsDecl GhcPs)
87updateHsmodDecl :: Traversal' (LHsDecl GhcPs) (HsDecl GhcPs)
89updateHsmodDecl = traverse
88updateHsmodDecl = traverse
91−updateHsDecl :: Traversal' (HsDecl GhcPs) (Sig GhcPs)
90+updateHsDecl :: Traversal' (HsDecl GhcPs) (LHsSigWcType GhcPs)
92−updateHsDecl f (SigD xSig s) = SigD xSig <$> f s
91+updateHsDecl f (SigD xSig s) = SigD xSig <$> updateSig f s
92+updateHsDecl f (ValD xVal hsBind) = ValD xVal <$> updateHsBind f hsBind
93updateHsDecl _ sig = pure sig
93updateHsDecl _ sig = pure sig
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
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
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
108+updateLLMatch :: Traversal' (Located [LMatch GhcPs (LHsExpr GhcPs)]) (LHsSigWcType GhcPs)
109+updateLLMatch = updateLocated updateLMatches
111+updateLMatches :: Traversal' [LMatch GhcPs (LHsExpr GhcPs)] (LHsSigWcType GhcPs)
112+updateLMatches f = traverse (updateLocated updateMatch f)
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
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
126+updateLHsLocalBinds :: Traversal' (LHsLocalBinds GhcPs) (LHsSigWcType GhcPs)
127+updateLHsLocalBinds = updateLocated updateLocalBinds
129+updateLocalBinds :: Traversal' (HsLocalBinds GhcPs) (LHsSigWcType GhcPs)
130+updateLocalBinds f (HsValBinds xHsValBinds hsValBindsLR) = HsValBinds xHsValBinds <$> updateHsValBindsLR f hsValBindsLR
131+updateLocalBinds _ hsValBinds = pure hsValBinds
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
137+updateLSigs :: Traversal' [LSig GhcPs] (LHsSigWcType GhcPs)
138+updateLSigs f = traverse (updateLocated updateSig f)
95updateSig :: Traversal' (Sig GhcPs) (LHsSigWcType GhcPs)
140updateSig :: Traversal' (Sig GhcPs) (LHsSigWcType GhcPs)
96updateSig f (TypeSig xSig ls t) = TypeSig xSig ls <$> f t
141updateSig f (TypeSig xSig ls t) = TypeSig xSig ls <$> f t
97updateSig _ sig = pure sig
142updateSig _ sig = pure sig
@@ -123,7 +168,7 @@ updateHsType ty@HsAppTy {} =
123 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)
168 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)
124updateHsType ty@HsFunTy {} =
169updateHsType ty@HsFunTy {} =
125 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)
170 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)
126−updateHsType ty@HsListTy {} =
171+updateHsType ty@HsListTy {} =
127 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)
172 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)
128updateHsType ty@HsTupleTy {} =
173updateHsType ty@HsTupleTy {} =
129 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)
174 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)