pub fn eval_literal_elim(
    prims: &prim::Env,
    metas: &meta::Env,
    scrutinee: Rc<Value>,
    closure: LiteralClosure,
) -> Result<Rc<Value>, String> {
    match scrutinee.as_ref() {
        Value::LiteralIntro(literal_intro) => {
            let index = closure.clauses.binary_search_by(|(l, _)| {
                l.partial_cmp(literal_intro).unwrap() // NaN?
            });

            let clause_body = match index {
                Ok(index) => &closure.clauses.get(index).unwrap().1,
                Err(_) => &closure.default,
            };
            eval_term(prims, metas, &closure.values, clause_body)
        },
        Value::Neutral(head, spine) => {
            let mut spine = spine.clone();
            spine.push(Elim::Literal(closure));
            Ok(Rc::from(Value::Neutral(head.clone(), spine)))
        },
        _ => Err("eval_literal_elim: not a literal".to_owned()),
    }
}
/// Case split on a literal.
Case split on a literal.
Case split on a literal .
pub fn eval_literal_elim(
    prims: &prim::Env,
    metas: &meta::Env,
    scrutinee: Rc<Value>,
    closure: LiteralClosure,
) -> Result<Rc<Value>, String> {
    match scrutinee.as_ref() {
        Value::LiteralIntro(literal_intro) => {
            let index = closure.clauses.binary_search_by(|(l, _)| {
                l.partial_cmp(literal_intro).unwrap() // NaN?
            });
            let clause_body = match index {
                Ok(index) => &closure.clauses.get(index).unwrap().1,
                Err(_) => &closure.default,
            };
            eval_term(prims, metas, &closure.values, clause_body)
        },
        Value::Neutral(head, spine) => {
            let mut spine = spine.clone();
            spine.push(Elim::Literal(closure));
            Ok(Rc::from(Value::Neutral(head.clone(), spine)))
        },
        _ => Err("eval_literal_elim: not a literal".to_owned()),
    }
}
pub fn eval_literal_elim ( prims : & prim :: Env , metas : & meta :: Env , scrutinee : Rc < Value > , closure : LiteralClosure , ) -> Result < Rc < Value > , String > { match scrutinee . as_ref ( ) { Value :: LiteralIntro ( literal_intro ) => { let index = closure . clauses . binary_search_by ( | ( l , _ ) | { l . partial_cmp ( literal_intro ) . unwrap ( ) // NaN? } ) ; let clause_body = match index { Ok ( index ) => & closure . clauses . get ( index ) . unwrap ( ) . 1 , Err ( _ ) => & closure . default , } ; eval_term ( prims , metas , & closure . values , clause_body ) } , Value :: Neutral ( head , spine ) => { let mut spine = spine . clone ( ) ; spine . push ( Elim :: Literal ( closure ) ) ; Ok ( Rc :: from ( Value :: Neutral ( head . clone ( ) , spine ) ) ) } , _ => Err ( " " . to_owned ( ) ) , } }
Case split on a literal.
Case split on a literal .
prims
&prim::Env
metas
&meta::Env
scrutinee
Rc<Value>
closure
LiteralClosure
prims
&prim::Env
metas
&meta::Env
scrutinee
Rc<Value>
closure
LiteralClosure