pub fn do_fun_elim(fun: RcValue, app_mode: AppMode, arg: RcValue) -> Result<RcValue, NbeError> {
    match fun.as_ref() {
        Value::FunIntro(fun_app_mode, body) => {
            if *fun_app_mode == app_mode {
                do_closure_app(body, arg)
            } else {
                Err(NbeError::new(format!(
                    "do_ap: unexpected application mode - {:?} != {:?}",
                    fun_app_mode, app_mode,
                )))
            }
        },
        Value::Neutral(head, spine) => {
            let mut spine = spine.clone();
            spine.push(Elim::Fun(app_mode, arg));
            Ok(RcValue::from(Value::Neutral(*head, spine)))
        },
        _ => Err(NbeError::new("do_ap: not a function")),
    }
}
/// Apply a function to an argument
Apply a function to an argument
Apply a function to an argument
pub fn do_fun_elim(fun: RcValue, app_mode: AppMode, arg: RcValue) -> Result<RcValue, NbeError> {
    match fun.as_ref() {
        Value::FunIntro(fun_app_mode, body) => {
            if *fun_app_mode == app_mode {
                do_closure_app(body, arg)
            } else {
                Err(NbeError::new(format!(
                    "do_ap: unexpected application mode - {:?} != {:?}",
                    fun_app_mode, app_mode,
                )))
            }
        },
        Value::Neutral(head, spine) => {
            let mut spine = spine.clone();
            spine.push(Elim::Fun(app_mode, arg));
            Ok(RcValue::from(Value::Neutral(*head, spine)))
        },
        _ => Err(NbeError::new("do_ap: not a function")),
    }
}
pub fn do_fun_elim ( fun : RcValue , app_mode : AppMode , arg : RcValue ) -> Result < RcValue , NbeError > { match fun . as_ref ( ) { Value :: FunIntro ( fun_app_mode , body ) => { if * fun_app_mode == app_mode { do_closure_app ( body , arg ) } else { Err ( NbeError :: new ( format ! ( " " fun_app_mode app_mode ) ) ) } } , Value :: Neutral ( head , spine ) => { let mut spine = spine . clone ( ) ; spine . push ( Elim :: Fun ( app_mode , arg ) ) ; Ok ( RcValue :: from ( Value :: Neutral ( * head , spine ) ) ) } , _ => Err ( NbeError :: new ( " " ) ) , } }
Apply a function to an argument
Apply a function to an argument
fun
RcValue
app_mode
AppMode
arg
RcValue