/// Apply a function to an argument.
Apply a function to an argument.
Apply a function to an argument .
pub fn eval_fun_elim(
    prims: &prim::Env,
    metas: &meta::Env,
    fun: Rc<Value>,
    app_mode: &AppMode,
    arg: Rc<Value>,
) -> Result<Rc<Value>, String> {
    match fun.as_ref() {
        Value::FunIntro(fun_app_mode, _, body) => {
            if fun_app_mode == app_mode {
                app_closure(prims, metas, body, arg)
            } else {
                Err(format!(
                    "eval_ap: unexpected application mode - {:?} != {:?}",
                    fun_app_mode, app_mode,
                ))
            }
        },
        Value::Neutral(head, spine) => {
            let mut spine = spine.clone();
            spine.push(Elim::Fun(app_mode.clone(), arg));
            // TODO: If head is `primitive`, and arity == number of initial spine apps in NF
            Ok(Rc::from(Value::Neutral(head.clone(), spine)))
        },
        _ => Err("eval_ap: not a function".to_owned()),
    }
}
pub fn eval_fun_elim ( prims : & prim :: Env , metas : & meta :: Env , fun : Rc < Value > , app_mode : & AppMode , arg : Rc < Value > , ) -> Result < Rc < Value > , String > { match fun . as_ref ( ) { Value :: FunIntro ( fun_app_mode , _ , body ) => { if fun_app_mode == app_mode { app_closure ( prims , metas , body , arg ) } else { Err ( format ! ( " " fun_app_mode app_mode ) ) } } , Value :: Neutral ( head , spine ) => { let mut spine = spine . clone ( ) ; spine . push ( Elim :: Fun ( app_mode . clone ( ) , arg ) ) ; // TODO: If head is `primitive`, and arity == number of initial spine apps in NF Ok ( Rc :: from ( Value :: Neutral ( head . clone ( ) , spine ) ) ) } , _ => Err ( " " . to_owned ( ) ) , } }
Apply a function to an argument.
Apply a function to an argument .
prims
&prim::Env
metas
&meta::Env
fun
Rc<Value>
app_mode
&AppMode
arg
Rc<Value>