From 9b897194ca65646794bb8763eb401bea127be66f Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Thu, 30 Nov 2023 01:30:04 -0600 Subject: [PATCH] ok kinda works? --- bidir/src/bidir_debruijn.rs | 11 +++++------ bidir/src/data_debruijn.rs | 8 ++++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/bidir/src/bidir_debruijn.rs b/bidir/src/bidir_debruijn.rs index c026266..0d32627 100644 --- a/bidir/src/bidir_debruijn.rs +++ b/bidir/src/bidir_debruijn.rs @@ -203,26 +203,25 @@ pub fn synthesize(ctx: &Context, term: &Term) -> Result<(Type, Context)> { let ex_b_2 = ex_b.transform_with_visitor(&V(1, aug_ctx.size()))?; let e_2 = e.transform_with_visitor(&V(0, aug_ctx.size()))?; - println!("---"); let wtf_ctx = typecheck(&aug_ctx, &e_2, &ex_b_2)?; let (before_marker, after_marker) = wtf_ctx.split_at(&marker_idx); // Bump the levels down since we're splitting teh array - struct V2(usize); + struct V2(usize, usize); impl Visitor for V2 { fn visit_index(&self, index: &mut ContextIndex) -> Result<()> { - index.debruijn_level -= 1; - index.debruijn_index = self.0 - 1 - index.debruijn_level; + index.debruijn_level -= self.0; + index.debruijn_index = self.1 - 1 - index.debruijn_level; Ok(()) } } let after_marker = - after_marker.transform_with_visitor(&V2(after_marker.size()))?; + after_marker.transform_with_visitor(&V2(0, after_marker.size()))?; let tau = Type::Arrow(Box::new(ex_a_2), Box::new(ex_b)); - println!("pre-tau: {tau:?} (in {after_marker:?})"); let tau = app_ctx(&after_marker, &tau)?; + let tau = tau.transform_with_visitor(&V2(1, after_marker.size()))?; // let (final_ctx, gen_idx) = // before_marker.add(ContextEntry::ExistentialVar); diff --git a/bidir/src/data_debruijn.rs b/bidir/src/data_debruijn.rs index bdf9f57..02de997 100644 --- a/bidir/src/data_debruijn.rs +++ b/bidir/src/data_debruijn.rs @@ -232,7 +232,11 @@ impl Type { Type::Existential(index) } Type::Polytype(_) => todo!(), - Type::Arrow(_, _) => todo!(), + Type::Arrow(a, b) => { + let a = a.transform_with_visitor(visitor)?; + let b = b.transform_with_visitor(visitor)?; + Type::Arrow(Box::new(a), Box::new(b)) + } _ => ty, }; visitor.visit_type_after(&mut ty)?; @@ -348,7 +352,7 @@ pub struct Context { impl fmt::Debug for Context { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "ᴦ{:?}", self.vector) + write!(f, "Γ{:?}", self.vector) } }