Skip to content

Commit ca48c9c

Browse files
doliogithub-actions[bot]
authored andcommitted
automatically run ormolu
1 parent 59eaddd commit ca48c9c

File tree

1 file changed

+15
-16
lines changed
  • unison-runtime/src/Unison/Runtime

1 file changed

+15
-16
lines changed

unison-runtime/src/Unison/Runtime/ANF.hs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -696,9 +696,9 @@ pattern ST1 d v m s = ST d [v] [m] s
696696
-- All variables, both bound and free occurring in a CTE. This is
697697
-- useful for avoiding both free and bound variables when
698698
-- freshening.
699-
cteVars :: Ord v => Cte v -> Set v
699+
cteVars :: (Ord v) => Cte v -> Set v
700700
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)
702702

703703
data ANormalF v e
704704
= ALet (Direction Word16) [Mem] e e
@@ -1721,7 +1721,7 @@ renameCtx :: (Var v) => v -> v -> Ctx v -> (Ctx v, Bool)
17211721
renameCtx v u (d, ctx) | (ctx, b) <- renameCtes v u ctx = ((d, ctx), b)
17221722

17231723
-- 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)
17251725
renameCtes v u = rn []
17261726
where
17271727
swap w
@@ -1744,7 +1744,7 @@ renameCtes v u = rn []
17441744
--
17451745
-- Assumes that the variables being renamed to are not bound by the
17461746
-- 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]
17481748
renamesCtes rn = map f
17491749
where
17501750
swap w
@@ -1757,10 +1757,10 @@ renamesCtes rn = map f
17571757
-- Calculates the free variables occurring in a context. This
17581758
-- consists of the free variables in the expressions being bound,
17591759
-- but with previously bound variables subtracted.
1760-
freeVarsCtx :: Ord v => Ctx v -> Set v
1760+
freeVarsCtx :: (Ord v) => Ctx v -> Set v
17611761
freeVarsCtx = freeVarsCte . snd
17621762

1763-
freeVarsCte :: Ord v => [Cte v] -> Set v
1763+
freeVarsCte :: (Ord v) => [Cte v] -> Set v
17641764
freeVarsCte = foldr m Set.empty
17651765
where
17661766
m (ST _ vs _ bn) rest =
@@ -1778,7 +1778,7 @@ freeVarsCte = foldr m Set.empty
17781778
-- Presumably any variables selected by the predicate should be
17791779
-- included in the set, but the set may contain additional variables
17801780
-- 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])
17821782
freshens p avoid0 vs =
17831783
mapAccumL f (Set.union avoid0 (Set.fromList vs)) vs
17841784
where
@@ -1805,15 +1805,15 @@ freshenCtx avoid0 (d, ctx) =
18051805
lavoid =
18061806
foldl (flip $ Set.union . cteVars) avoid0 ctx
18071807

1808-
go _ rns fresh [] = (rns, fresh)
1808+
go _ rns fresh [] = (rns, fresh)
18091809
go avoid rns fresh (bn : bns) = case bn of
18101810
LZ v r as
18111811
| v `Set.member` avoid0,
18121812
u <- Var.freshIn avoid v,
18131813
(fresh, _) <- renameCtes v u fresh,
18141814
avoid <- Set.insert u avoid,
18151815
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
18171817
ST d vs ccs expr
18181818
| (avoid, us) <- freshens (`Set.member` avoid0) avoid vs,
18191819
rn <- Map.fromList (filter (uncurry (/=)) $ zip vs us),
@@ -1822,7 +1822,7 @@ freshenCtx avoid0 (d, ctx) =
18221822
-- Note: rns union left-biased, so inner contexts take
18231823
-- priority.
18241824
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
18261826
_ -> go avoid rns (bn : fresh) bns
18271827

18281828
anfBlock :: (Ord v, Var v) => Term v a -> ANFM v (Ctx v, DNormal v)
@@ -1988,12 +1988,11 @@ anfBlock (Let1Named' v b e) =
19881988
let octx = bctx <> directed [ST1 d v BX cb] <> ectx
19891989
pure (octx, ce)
19901990
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
19971996
anfBlock (Apps' (Blank' b) args) = do
19981997
nm <- fresh
19991998
(actx, cas) <- anfArgs args

0 commit comments

Comments
 (0)