pub fn check_clause(
    context: &Context,
    mut clause: Clause<'_>,
    expected_ty: &domain::RcType,
) -> Result<core::RcTerm, Diagnostic<FileSpan>> {
    let mut context = context.clone();
    let mut param_app_modes = Vec::new();
    let mut expected_ty = expected_ty.clone();

    while let (Some((app_mode, param_ty, next_body_ty)), Some((head_param, rest_params))) = (
        next_expected_param(&mut std::iter::empty(), &expected_ty),
        clause.concrete_params.split_first(),
    ) {
        let var_name = match check_param_app_mode(head_param, &app_mode)? {
            None => None,
            Some(pattern) => {
                clause.concrete_params = rest_params;
                match pattern.as_ref() {
                    Pattern::Var(var_name) => Some(var_name.to_string()),
                }
            },
        };

        param_app_modes.push(app_mode);
        let param_var = context.local_bind(var_name, param_ty.clone());
        if let Some(next_body_ty) = next_body_ty {
            expected_ty = do_closure_app(&next_body_ty, param_var)?;
        }
    }

    let body = check_clause_body(&context, &clause, &expected_ty)?;

    Ok(done(vec![], param_app_modes, body))
}
/// Check that a given clause conforms to an expected type, and elaborates
/// it into a case tree.
///
/// Returns the elaborated term.
Check that a given clause conforms to an expected type, and elaborates
it into a case tree.

Returns the elaborated term.
Check that a given clause conforms to an expected type and elaborates it into a case tree . Returns the elaborated term .
pub fn check_clause(
    context: &Context,
    mut clause: Clause<'_>,
    expected_ty: &domain::RcType,
) -> Result<core::RcTerm, Diagnostic<FileSpan>> {
    let mut context = context.clone();
    let mut param_app_modes = Vec::new();
    let mut expected_ty = expected_ty.clone();
    while let (Some((app_mode, param_ty, next_body_ty)), Some((head_param, rest_params))) = (
        next_expected_param(&mut std::iter::empty(), &expected_ty),
        clause.concrete_params.split_first(),
    ) {
        let var_name = match check_param_app_mode(head_param, &app_mode)? {
            None => None,
            Some(pattern) => {
                clause.concrete_params = rest_params;
                match pattern.as_ref() {
                    Pattern::Var(var_name) => Some(var_name.to_string()),
                }
            },
        };
        param_app_modes.push(app_mode);
        let param_var = context.local_bind(var_name, param_ty.clone());
        if let Some(next_body_ty) = next_body_ty {
            expected_ty = do_closure_app(&next_body_ty, param_var)?;
        }
    }
    let body = check_clause_body(&context, &clause, &expected_ty)?;
    Ok(done(vec![], param_app_modes, body))
}
pub fn check_clause ( context : & Context , mut clause : Clause < ' _ > , expected_ty : & domain :: RcType , ) -> Result < core :: RcTerm , Diagnostic < FileSpan > > { let mut context = context . clone ( ) ; let mut param_app_modes = Vec :: new ( ) ; let mut expected_ty = expected_ty . clone ( ) ; while let ( Some ( ( app_mode , param_ty , next_body_ty ) ) , Some ( ( head_param , rest_params ) ) ) = ( next_expected_param ( & mut std :: iter :: empty ( ) , & expected_ty ) , clause . concrete_params . split_first ( ) , ) { let var_name = match check_param_app_mode ( head_param , & app_mode ) ? { None => None , Some ( pattern ) => { clause . concrete_params = rest_params ; match pattern . as_ref ( ) { Pattern :: Var ( var_name ) => Some ( var_name . to_string ( ) ) , } } , } ; param_app_modes . push ( app_mode ) ; let param_var = context . local_bind ( var_name , param_ty . clone ( ) ) ; if let Some ( next_body_ty ) = next_body_ty { expected_ty = do_closure_app ( & next_body_ty , param_var ) ? ; } } let body = check_clause_body ( & context , & clause , & expected_ty ) ? ; Ok ( done ( vec ! [ ] , param_app_modes , body ) ) }
Check that a given clause conforms to an expected type, and elaborates
it into a case tree.
Check that a given clause conforms to an expected type and elaborates it into a case tree .
context
&Context
clause
Clause<'_>
expected_ty
&domain::RcType