refactor(frontends/lean/type_util): move infer_implicit_params to library
This commit is contained in:
parent
65cc4d3c08
commit
a53098385c
4 changed files with 24 additions and 22 deletions
|
@ -51,20 +51,4 @@ implicit_infer_kind parse_implicit_infer_modifier(parser & p) {
|
|||
return implicit_infer_kind::Implicit;
|
||||
}
|
||||
}
|
||||
|
||||
expr infer_implicit_params(expr const & type, unsigned nparams, implicit_infer_kind k) {
|
||||
switch (k) {
|
||||
case implicit_infer_kind::Implicit: {
|
||||
bool strict = true;
|
||||
return infer_implicit(type, nparams, strict);
|
||||
}
|
||||
case implicit_infer_kind::RelaxedImplicit: {
|
||||
bool strict = false;
|
||||
return infer_implicit(type, nparams, strict);
|
||||
}
|
||||
case implicit_infer_kind::None:
|
||||
return type;
|
||||
}
|
||||
lean_unreachable(); // LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
Author: Leonardo de Moura
|
||||
*/
|
||||
#pragma once
|
||||
#include "library/util.h"
|
||||
|
||||
namespace lean {
|
||||
class parser;
|
||||
|
@ -35,7 +36,6 @@ public:
|
|||
environment add_alias(parser & p, environment env, bool composite,
|
||||
name const & full_id, levels const & ctx_levels, buffer<expr> const & ctx_params);
|
||||
|
||||
enum class implicit_infer_kind { Implicit, RelaxedImplicit, None };
|
||||
/**
|
||||
\brief Parse implicit parameter inference modifiers.
|
||||
|
||||
|
@ -44,9 +44,4 @@ enum class implicit_infer_kind { Implicit, RelaxedImplicit, None };
|
|||
Return implicit_infer_kind::Implicit, otherwise.
|
||||
*/
|
||||
implicit_infer_kind parse_implicit_infer_modifier(parser & p);
|
||||
|
||||
/** \brief Infer implicit parameter annotations for the first \c nparams using mode
|
||||
specified by \c k.
|
||||
*/
|
||||
expr infer_implicit_params(expr const & type, unsigned nparams, implicit_infer_kind k);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ Author: Leonardo de Moura
|
|||
#include "kernel/type_checker.h"
|
||||
#include "kernel/inductive/inductive.h"
|
||||
#include "library/locals.h"
|
||||
#include "library/util.h"
|
||||
|
||||
namespace lean {
|
||||
bool is_def_app(environment const & env, expr const & e) {
|
||||
|
@ -504,4 +505,19 @@ expr mk_sigma_mk(type_checker & tc, buffer<expr> const & ts, buffer<expr> const
|
|||
return mk_sigma_mk(tc, ts.size(), ts.data(), as.data(), cs);
|
||||
}
|
||||
|
||||
expr infer_implicit_params(expr const & type, unsigned nparams, implicit_infer_kind k) {
|
||||
switch (k) {
|
||||
case implicit_infer_kind::Implicit: {
|
||||
bool strict = true;
|
||||
return infer_implicit(type, nparams, strict);
|
||||
}
|
||||
case implicit_infer_kind::RelaxedImplicit: {
|
||||
bool strict = false;
|
||||
return infer_implicit(type, nparams, strict);
|
||||
}
|
||||
case implicit_infer_kind::None:
|
||||
return type;
|
||||
}
|
||||
lean_unreachable(); // LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,6 +132,13 @@ level mk_max(levels const & ls);
|
|||
|
||||
expr mk_sigma_mk(type_checker & tc, buffer<expr> const & ts, buffer<expr> const & as, constraint_seq & cs);
|
||||
|
||||
enum class implicit_infer_kind { Implicit, RelaxedImplicit, None };
|
||||
|
||||
/** \brief Infer implicit parameter annotations for the first \c nparams using mode
|
||||
specified by \c k.
|
||||
*/
|
||||
expr infer_implicit_params(expr const & type, unsigned nparams, implicit_infer_kind k);
|
||||
|
||||
void initialize_library_util();
|
||||
void finalize_library_util();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue