@@ -696,9 +696,9 @@ pattern ST1 d v m s = ST d [v] [m] s
696
696
-- All variables, both bound and free occurring in a CTE. This is
697
697
-- useful for avoiding both free and bound variables when
698
698
-- freshening.
699
- cteVars :: Ord v => Cte v -> Set v
699
+ cteVars :: ( Ord v ) => Cte v -> Set v
700
700
cteVars (ST _ vs _ e) = Set. fromList vs `Set.union` ABTN. freeVars e
701
- cteVars (LZ v r as) = Set. fromList (either (const id ) (:) r $ v: as)
701
+ cteVars (LZ v r as) = Set. fromList (either (const id ) (:) r $ v : as)
702
702
703
703
data ANormalF v e
704
704
= ALet (Direction Word16 ) [Mem ] e e
@@ -1721,7 +1721,7 @@ renameCtx :: (Var v) => v -> v -> Ctx v -> (Ctx v, Bool)
1721
1721
renameCtx v u (d, ctx) | (ctx, b) <- renameCtes v u ctx = ((d, ctx), b)
1722
1722
1723
1723
-- As above, but without the Direction.
1724
- renameCtes :: Var v => v -> v -> [Cte v ] -> ([Cte v ], Bool )
1724
+ renameCtes :: ( Var v ) => v -> v -> [Cte v ] -> ([Cte v ], Bool )
1725
1725
renameCtes v u = rn []
1726
1726
where
1727
1727
swap w
@@ -1744,7 +1744,7 @@ renameCtes v u = rn []
1744
1744
--
1745
1745
-- Assumes that the variables being renamed to are not bound by the
1746
1746
-- context entries, so that it is unnecessary to rename them.
1747
- renamesCtes :: Var v => Map v v -> [Cte v ] -> [Cte v ]
1747
+ renamesCtes :: ( Var v ) => Map v v -> [Cte v ] -> [Cte v ]
1748
1748
renamesCtes rn = map f
1749
1749
where
1750
1750
swap w
@@ -1757,10 +1757,10 @@ renamesCtes rn = map f
1757
1757
-- Calculates the free variables occurring in a context. This
1758
1758
-- consists of the free variables in the expressions being bound,
1759
1759
-- but with previously bound variables subtracted.
1760
- freeVarsCtx :: Ord v => Ctx v -> Set v
1760
+ freeVarsCtx :: ( Ord v ) => Ctx v -> Set v
1761
1761
freeVarsCtx = freeVarsCte . snd
1762
1762
1763
- freeVarsCte :: Ord v => [Cte v ] -> Set v
1763
+ freeVarsCte :: ( Ord v ) => [Cte v ] -> Set v
1764
1764
freeVarsCte = foldr m Set. empty
1765
1765
where
1766
1766
m (ST _ vs _ bn) rest =
@@ -1778,7 +1778,7 @@ freeVarsCte = foldr m Set.empty
1778
1778
-- Presumably any variables selected by the predicate should be
1779
1779
-- included in the set, but the set may contain additional variables
1780
1780
-- to avoid, when freshening.
1781
- freshens :: Var v => (v -> Bool ) -> Set v -> [v ] -> (Set v , [v ])
1781
+ freshens :: ( Var v ) => (v -> Bool ) -> Set v -> [v ] -> (Set v , [v ])
1782
1782
freshens p avoid0 vs =
1783
1783
mapAccumL f (Set. union avoid0 (Set. fromList vs)) vs
1784
1784
where
@@ -1805,15 +1805,15 @@ freshenCtx avoid0 (d, ctx) =
1805
1805
lavoid =
1806
1806
foldl (flip $ Set. union . cteVars) avoid0 ctx
1807
1807
1808
- go _ rns fresh [] = (rns, fresh)
1808
+ go _ rns fresh [] = (rns, fresh)
1809
1809
go avoid rns fresh (bn : bns) = case bn of
1810
1810
LZ v r as
1811
1811
| v `Set.member` avoid0,
1812
1812
u <- Var. freshIn avoid v,
1813
1813
(fresh, _) <- renameCtes v u fresh,
1814
1814
avoid <- Set. insert u avoid,
1815
1815
rns <- Map. alter (Just . fromMaybe u) v rns ->
1816
- go avoid rns (LZ u r as : fresh) bns
1816
+ go avoid rns (LZ u r as : fresh) bns
1817
1817
ST d vs ccs expr
1818
1818
| (avoid, us) <- freshens (`Set.member` avoid0) avoid vs,
1819
1819
rn <- Map. fromList (filter (uncurry (/=) ) $ zip vs us),
@@ -1822,7 +1822,7 @@ freshenCtx avoid0 (d, ctx) =
1822
1822
-- Note: rns union left-biased, so inner contexts take
1823
1823
-- priority.
1824
1824
rns <- Map. union rns rn ->
1825
- go avoid rns (ST d us ccs expr : fresh) bns
1825
+ go avoid rns (ST d us ccs expr : fresh) bns
1826
1826
_ -> go avoid rns (bn : fresh) bns
1827
1827
1828
1828
anfBlock :: (Ord v , Var v ) => Term v a -> ANFM v (Ctx v , DNormal v )
@@ -1988,12 +1988,11 @@ anfBlock (Let1Named' v b e) =
1988
1988
let octx = bctx <> directed [ST1 d v BX cb] <> ectx
1989
1989
pure (octx, ce)
1990
1990
where
1991
- fixupBctx bctx ectx (_, ce) =
1992
- pure $ freshenCtx (Set. union ecfvs efvs) bctx
1993
- where
1994
- ecfvs = freeVarsCtx ectx
1995
- efvs = ABTN. freeVars ce
1996
-
1991
+ fixupBctx bctx ectx (_, ce) =
1992
+ pure $ freshenCtx (Set. union ecfvs efvs) bctx
1993
+ where
1994
+ ecfvs = freeVarsCtx ectx
1995
+ efvs = ABTN. freeVars ce
1997
1996
anfBlock (Apps' (Blank' b) args) = do
1998
1997
nm <- fresh
1999
1998
(actx, cas) <- anfArgs args
0 commit comments