Skip to content

Commit

Permalink
Annoying naming
Browse files Browse the repository at this point in the history
  • Loading branch information
vrindisbacher committed Jan 19, 2025
1 parent 4fdc4f4 commit f6e0bb2
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions src/Language/Fixpoint/Types/Visitor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ fold v c a t = snd $ execVisitM v c a visit t
-- trans :: (Visitable t, Monoid a) => Visitor a ctx -> ctx -> a -> t -> t
-- trans !v !c !_ !z = fst $ execVisitM v c mempty visit z

class Foldable t where
foldE :: (Expr -> Expr) -> t -> t
class Translatable t where
transE :: (Expr -> Expr) -> t -> t

trans :: Foldable t => (Expr -> Expr) -> t -> t
trans f t = foldE f t
trans :: Translatable t => (Expr -> Expr) -> t -> t
trans f t = transE f t

instance Foldable Expr where
foldE f = go
instance Translatable Expr where
transE f = go
where
go !e0 = f $! case e0 of
EApp f e ->
Expand Down Expand Up @@ -170,50 +170,50 @@ instance Foldable Expr where
e@ESym{} -> e
e@ECon{} -> e

instance Foldable Reft where
foldE v (Reft (x, ra)) = Reft (x, foldE v ra)
instance Translatable Reft where
transE v (Reft (x, ra)) = Reft (x, transE v ra)

instance Foldable SortedReft where
foldE v (RR t r) = RR t (foldE v r)
instance Translatable SortedReft where
transE v (RR t r) = RR t (transE v r)

instance Foldable (Symbol, SortedReft, a) where
foldE f (sym, sr, a) = (sym, foldE f sr, a)
instance Translatable (Symbol, SortedReft, a) where
transE f (sym, sr, a) = (sym, transE f sr, a)

instance Foldable (BindEnv a) where
foldE v be = be { beBinds = M.map (foldE v) (beBinds be) }
instance Translatable (BindEnv a) where
transE v be = be { beBinds = M.map (transE v) (beBinds be) }

instance (Foldable (c a)) => Foldable (GInfo c a) where
foldE f x = x {
cm = foldE f <$> cm x
, bs = foldE f (bs x)
, ae = foldE f (ae x)
instance (Translatable (c a)) => Translatable (GInfo c a) where
transE f x = x {
cm = transE f <$> cm x
, bs = transE f (bs x)
, ae = transE f (ae x)
}

instance Foldable (SimpC a) where
foldE v x = x {
_crhs = foldE v (_crhs x)
instance Translatable (SimpC a) where
transE v x = x {
_crhs = transE v (_crhs x)
}

instance Foldable (SubC a) where
foldE v x = x {
slhs = foldE v (slhs x),
srhs = foldE v (srhs x)
instance Translatable (SubC a) where
transE v x = x {
slhs = transE v (slhs x),
srhs = transE v (srhs x)
}

instance Foldable AxiomEnv where
foldE v x = x {
aenvEqs = foldE v <$> aenvEqs x,
aenvSimpl = foldE v <$> aenvSimpl x
instance Translatable AxiomEnv where
transE v x = x {
aenvEqs = transE v <$> aenvEqs x,
aenvSimpl = transE v <$> aenvSimpl x
}

instance Foldable Equation where
foldE v eq = eq {
eqBody = foldE v (eqBody eq)
instance Translatable Equation where
transE v eq = eq {
eqBody = transE v (eqBody eq)
}

instance Foldable Rewrite where
foldE v rw = rw {
smBody = foldE v (smBody rw)
instance Translatable Rewrite where
transE v rw = rw {
smBody = transE v (smBody rw)
}

execVisitM :: Visitor a ctx -> ctx -> a -> (Visitor a ctx -> ctx -> t -> VisitM a t) -> t -> (t, a)
Expand Down Expand Up @@ -317,12 +317,12 @@ visitExpr !v = vE
step _ p@(PKVar _ _) = return p
step !c (PGrad k su i e) = PGrad k su i <$> vE c e

mapKVars :: Foldable t => (KVar -> Maybe Expr) -> t -> t
mapKVars :: Translatable t => (KVar -> Maybe Expr) -> t -> t
mapKVars f = mapKVars' f'
where
f' (kv', _) = f kv'

mapKVars' :: Foldable t => ((KVar, Subst) -> Maybe Expr) -> t -> t
mapKVars' :: Translatable t => ((KVar, Subst) -> Maybe Expr) -> t -> t
mapKVars' f = trans txK
where
txK (PKVar k su)
Expand All @@ -333,7 +333,7 @@ mapKVars' f = trans txK



mapGVars' :: Foldable t => ((KVar, Subst) -> Maybe Expr) -> t -> t
mapGVars' :: Translatable t => ((KVar, Subst) -> Maybe Expr) -> t -> t
mapGVars' f = trans txK
where
txK (PGrad k su _ _)
Expand Down Expand Up @@ -372,7 +372,7 @@ mapMExpr f = go
go (PAnd ps) = f . PAnd =<< (go `traverse` ps)
go (POr ps) = f . POr =<< (go `traverse` ps)

mapKVarSubsts :: Foldable t => (KVar -> Subst -> Subst) -> t -> t
mapKVarSubsts :: Translatable t => (KVar -> Subst -> Subst) -> t -> t
mapKVarSubsts f = trans txK
where
txK (PKVar k su) = PKVar k (f k su)
Expand Down

0 comments on commit f6e0bb2

Please sign in to comment.