pub fn ivar_replace(e: &Expr, child: Id, map: &AHashMap<i32, Expr>) -> Expr {
    match e.get(child) {
        Lambda::IVar(i) => map.get(i).unwrap_or(e).clone(),
        Lambda::Var(v) => Expr::var(*v),
        Lambda::Prim(p) => Expr::prim(*p),
        Lambda::App([f,x]) => Expr::app(ivar_replace(e, *f, map), ivar_replace(e, *x, map)),
        Lambda::Lam([b]) => Expr::lam(ivar_replace(e, *b, map)),
        Lambda::Programs(_) => panic!("why would you do this")
    }
}
/// Replace the ivars in an expr based on an i32->Expr map
Replace the ivars in an expr based on an i32->Expr map
Replace the ivars in an expr based on an i32 - > Expr map
pub fn ivar_replace(e: &Expr, child: Id, map: &AHashMap<i32, Expr>) -> Expr {
    match e.get(child) {
        Lambda::IVar(i) => map.get(i).unwrap_or(e).clone(),
        Lambda::Var(v) => Expr::var(*v),
        Lambda::Prim(p) => Expr::prim(*p),
        Lambda::App([f,x]) => Expr::app(ivar_replace(e, *f, map), ivar_replace(e, *x, map)),
        Lambda::Lam([b]) => Expr::lam(ivar_replace(e, *b, map)),
        Lambda::Programs(_) => panic!("why would you do this")
    }
}
pub fn ivar_replace ( e : & Expr , child : Id , map : & AHashMap < i32 , Expr > ) -> Expr { match e . get ( child ) { Lambda :: IVar ( i ) => map . get ( i ) . unwrap_or ( e ) . clone ( ) , Lambda :: Var ( v ) => Expr :: var ( * v ) , Lambda :: Prim ( p ) => Expr :: prim ( * p ) , Lambda :: App ( [ f , x ] ) => Expr :: app ( ivar_replace ( e , * f , map ) , ivar_replace ( e , * x , map ) ) , Lambda :: Lam ( [ b ] ) => Expr :: lam ( ivar_replace ( e , * b , map ) ) , Lambda :: Programs ( _ ) => panic ! ( " " ) } }
Replace the ivars in an expr based on an i32->Expr map
Replace the ivars in an expr based on an i32 - > Expr map
e
&Expr
child
Id
map
&AHashMap<i32, Expr>
e
&Expr
child
Id
map
&AHashMap<i32, Expr>