pub fn infer_app(self, flag : InferFlag, tc : &mut Tc<'t, 'l, 'e>) -> Self {
        let (mut fun, mut args) = self.unfold_apps(tc);
        fun = fun.infer(flag, tc);
        let mut context = Nil::<Expr>.alloc(tc);

        while let Cons(hd, tl) = args.read(tc) {
            match fun.read(tc) {
                Pi { b_type, body, .. } => {
                    if flag == Check {
                        let arg_type = hd.infer(flag, tc);
                        b_type.inst(context, tc).assert_def_eq(arg_type, tc);
                    }

                    context = Cons(hd, context).alloc(tc);
                    args = tl;
                    fun = body;
                },
                _ => {
                    let as_pi = fun.inst(context, tc).ensure_pi(tc);
                    match as_pi.read(tc) {
                        Pi {..} => {
                            context = Nil::<Expr>.alloc(tc);
                            fun = as_pi;
                        },
                        _ => unreachable!("infer app could not produce a pi") 
                    }
                }
            }
        }
        fun.inst(context, tc)
    }
// Only makes sure that the Expr tree has the shape "some number of pis
// applied to an appropriate number of arguments". Since we know `flag` is
// InferOnly, we don't bother to check that the Pi's binder type
// is equal to the type of the argument.
Only makes sure that the Expr tree has the shape "some number of pis
applied to an appropriate number of arguments". Since we know `flag` is
InferOnly, we don't bother to check that the Pi's binder type
is equal to the type of the argument.
Only makes sure that the Expr tree has the shape " some number of pis applied to an appropriate number of arguments " . Since we know ` flag ` is InferOnly we don ' t bother to check that the Pi ' s binder type is equal to the type of the argument .
pub fn infer_app(self, flag : InferFlag, tc : &mut Tc<'t, 'l, 'e>) -> Self {
        let (mut fun, mut args) = self.unfold_apps(tc);
        fun = fun.infer(flag, tc);
        let mut context = Nil::<Expr>.alloc(tc);
        while let Cons(hd, tl) = args.read(tc) {
            match fun.read(tc) {
                Pi { b_type, body, .. } => {
                    if flag == Check {
                        let arg_type = hd.infer(flag, tc);
                        b_type.inst(context, tc).assert_def_eq(arg_type, tc);
                    }
                    context = Cons(hd, context).alloc(tc);
                    args = tl;
                    fun = body;
                },
                _ => {
                    let as_pi = fun.inst(context, tc).ensure_pi(tc);
                    match as_pi.read(tc) {
                        Pi {..} => {
                            context = Nil::<Expr>.alloc(tc);
                            fun = as_pi;
                        },
                        _ => unreachable!("infer app could not produce a pi") 
                    }
                }
            }
        }
        fun.inst(context, tc)
    }
pub fn infer_app ( self , flag : InferFlag , tc : & mut Tc < ' t , ' l , ' e > ) -> Self { let ( mut fun , mut args ) = self . unfold_apps ( tc ) ; fun = fun . infer ( flag , tc ) ; let mut context = Nil :: < Expr > . alloc ( tc ) ; while let Cons ( hd , tl ) = args . read ( tc ) { match fun . read ( tc ) { Pi { b_type , body , .. } => { if flag == Check { let arg_type = hd . infer ( flag , tc ) ; b_type . inst ( context , tc ) . assert_def_eq ( arg_type , tc ) ; } context = Cons ( hd , context ) . alloc ( tc ) ; args = tl ; fun = body ; } , _ => { let as_pi = fun . inst ( context , tc ) . ensure_pi ( tc ) ; match as_pi . read ( tc ) { Pi { .. } => { context = Nil :: < Expr > . alloc ( tc ) ; fun = as_pi ; } , _ => unreachable ! ( " " ) } } } } fun . inst ( context , tc ) }
Only makes sure that the Expr tree has the shape "some number of pis
applied to an appropriate number of arguments".
Only makes sure that the Expr tree has the shape " some number of pis applied to an appropriate number of arguments " .
self
flag
InferFlag
tc
&mut Tc<'t, 'l, 'e>
self
flag
InferFlag
tc
&mut Tc<'t, 'l, 'e>