diff --git a/docs/langs/explicit-substitution/reduce/lookup.cic b/docs/langs/explicit-substitution/reduce/lookup.cic index 46b7a18f..61e48854 100644 --- a/docs/langs/explicit-substitution/reduce/lookup.cic +++ b/docs/langs/explicit-substitution/reduce/lookup.cic @@ -3,11 +3,11 @@ import { Binding, Exp } from "../exp/index.cic" export function lookup( name: string, bindings: List(Binding), -): Optional(Exp) { +): Maybe(Exp) { let found = listFind( listReverse(bindings), (binding) => stringEqual(binding.name, name) ) - return optionalMap(found, (binding) => binding.exp) + return maybeMap(found, (binding) => binding.exp) } diff --git a/docs/langs/explicit-substitution/reduce/reduce.cic b/docs/langs/explicit-substitution/reduce/reduce.cic index b6f6fc85..43e8fb87 100644 --- a/docs/langs/explicit-substitution/reduce/reduce.cic +++ b/docs/langs/explicit-substitution/reduce/reduce.cic @@ -8,9 +8,9 @@ import { substitute } from "./substitute.cic" export function reduce(mod: Mod, exp: Exp): Exp { match (exp) { - case Exp::var(name) => { - let defintion = modFind(mod, name) - return if isNone(defintion) then exp else reduce(mod, defintion.exp) + case Exp::var(name) => match (modFind(mod, name)) { + case Maybe::just(defintion) => exp + case Maybe::nothing() => reduce(mod, defintion.exp) } case Exp::fn(name, ret) => diff --git a/docs/langs/explicit-substitution/reduce/substitute.cic b/docs/langs/explicit-substitution/reduce/substitute.cic index e73eca59..b87e9446 100644 --- a/docs/langs/explicit-substitution/reduce/substitute.cic +++ b/docs/langs/explicit-substitution/reduce/substitute.cic @@ -7,10 +7,10 @@ export function substitute( body: Exp, ): Exp { match (body) { - case Exp::Var(name) => { - let found = lookup(name, bindings) - return if isNone(found) then body else found - } + 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)