Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed May 1, 2024
1 parent 58850a5 commit 6b0d1e7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/langs/explicit-substitution/reduce/doAp.cic
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Mod } from "../mod/Mod.cic"
import { reduce } from "./reduce.cic"

export function doAp(mod: Mod, target: Exp, arg: Exp): Exp {
match target {
match (target) {
case Exp::Fn(name, ret) =>
reduce(mod, Exp::Let([new Binding(name, arg)], ret))

Expand Down
2 changes: 1 addition & 1 deletion docs/langs/explicit-substitution/reduce/lookup.cic
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export function lookup(
(binding) => stringEqual(binding.name, name)
)

return maybeMap(found, (binding) => binding.exp)
maybeMap(found, (binding) => binding.exp)
}
4 changes: 2 additions & 2 deletions docs/langs/explicit-substitution/reduce/reduce.cic
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { substitute } from "./substitute.cic"
// but it will always remove `Let`.

export function reduce(mod: Mod, exp: Exp): Exp {
match exp {
case Exp::Var(name) => match modFind(mod, name) {
match (exp) {
case Exp::Var(name) => match (modFind(mod, name)) {
case Maybe::Just(defintion) => exp
case Maybe::Nothing() => reduce(mod, defintion.exp)
}
Expand Down
10 changes: 5 additions & 5 deletions docs/langs/explicit-substitution/reduce/substitute.cic
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ export function substitute(
bindings: List(Binding),
body: Exp,
): Exp {
match body {
case Exp::Var(name) => match lookup(name, bindings) {
match (body) {
case Exp::Var(name) => match (lookup(name, bindings)) {
case Maybe::Just(exp) => exp
case Maybe::Nothing() => body
}

case Exp::Fn(name, ret) => {
let freshName = freshen(name)
return Exp::Fn(
let freshName = freshen(name
Exp::Fn(
freshName,
Exp::Let(
listAppend(bindings, [new Binding(name, Exp::Var(freshName))]),
Expand All @@ -41,5 +41,5 @@ function substituteBinding(
bindings: List(Binding),
binding: Binding,
): Binding {
return new Binding(binding.name, substitute(bindings, binding.exp))
new Binding(binding.name, substitute(bindings, binding.exp))
}

0 comments on commit 6b0d1e7

Please sign in to comment.