pub fn infer_pattern<Env>(
    env: &Env,
    raw_pattern: &raw::RcPattern,
) -> Result<(RcPattern, RcType, Vec<(FreeVar<String>, RcType)>), TypeError>
where
    Env: DeclarationEnv + DefinitionEnv,
{
    match *raw_pattern.inner {
        raw::Pattern::Ann(ref raw_pattern, Embed(ref raw_ty)) => {
            let (ty, _) = infer_universe(env, raw_ty)?;
            let value_ty = nf_term(env, &ty)?;
            let (pattern, declarations) = check_pattern(env, raw_pattern, &value_ty)?;

            Ok((
                RcPattern::from(Pattern::Ann(pattern, Embed(ty))),
                value_ty,
                declarations,
            ))
        },
        raw::Pattern::Literal(ref literal) => {
            let (literal, ty) = infer_literal(literal)?;
            Ok((RcPattern::from(Pattern::Literal(literal)), ty, vec![]))
        },
        raw::Pattern::Binder(span, ref binder) => Err(TypeError::BinderNeedsAnnotation {
            span,
            binder: binder.clone(),
        }),
    }
}
/// Synthesize the type of a pattern, returning the elaborated pattern, the
/// inferred type, and a vector of the declarations it introduced if successful
Synthesize the type of a pattern, returning the elaborated pattern, the
inferred type, and a vector of the declarations it introduced if successful
Synthesize the type of a pattern returning the elaborated pattern the inferred type and a vector of the declarations it introduced if successful
pub fn infer_pattern<Env>(
    env: &Env,
    raw_pattern: &raw::RcPattern,
) -> Result<(RcPattern, RcType, Vec<(FreeVar<String>, RcType)>), TypeError>
where
    Env: DeclarationEnv + DefinitionEnv,
{
    match *raw_pattern.inner {
        raw::Pattern::Ann(ref raw_pattern, Embed(ref raw_ty)) => {
            let (ty, _) = infer_universe(env, raw_ty)?;
            let value_ty = nf_term(env, &ty)?;
            let (pattern, declarations) = check_pattern(env, raw_pattern, &value_ty)?;
            Ok((
                RcPattern::from(Pattern::Ann(pattern, Embed(ty))),
                value_ty,
                declarations,
            ))
        },
        raw::Pattern::Literal(ref literal) => {
            let (literal, ty) = infer_literal(literal)?;
            Ok((RcPattern::from(Pattern::Literal(literal)), ty, vec![]))
        },
        raw::Pattern::Binder(span, ref binder) => Err(TypeError::BinderNeedsAnnotation {
            span,
            binder: binder.clone(),
        }),
    }
}
pub fn infer_pattern < Env > ( env : & Env , raw_pattern : & raw :: RcPattern , ) -> Result < ( RcPattern , RcType , Vec < ( FreeVar < String > , RcType ) > ) , TypeError > where Env : DeclarationEnv + DefinitionEnv , { match * raw_pattern . inner { raw :: Pattern :: Ann ( ref raw_pattern , Embed ( ref raw_ty ) ) => { let ( ty , _ ) = infer_universe ( env , raw_ty ) ? ; let value_ty = nf_term ( env , & ty ) ? ; let ( pattern , declarations ) = check_pattern ( env , raw_pattern , & value_ty ) ? ; Ok ( ( RcPattern :: from ( Pattern :: Ann ( pattern , Embed ( ty ) ) ) , value_ty , declarations , ) ) } , raw :: Pattern :: Literal ( ref literal ) => { let ( literal , ty ) = infer_literal ( literal ) ? ; Ok ( ( RcPattern :: from ( Pattern :: Literal ( literal ) ) , ty , vec ! [ ] ) ) } , raw :: Pattern :: Binder ( span , ref binder ) => Err ( TypeError :: BinderNeedsAnnotation { span , binder : binder . clone ( ) , } ) , } }
Synthesize the type of a pattern, returning the elaborated pattern, the
inferred type, and a vector of the declarations it introduced if successful
Synthesize the type of a pattern returning the elaborated pattern the inferred type and a vector of the declarations it introduced if successful
env
&Env
raw_pattern
&raw::RcPattern
env
&Env
raw_pattern
&raw::RcPattern