コード例 #1
0
format unification_app_mismatch_exception::pp(formatter const & fmt, options const & opts) const {
    unsigned indent     = get_pp_indent(opts);
    auto const & ctx    = get_context();
    expr const & app    = get_expr();
    auto args_it        = get_args().begin();
    auto args_end       = get_args().end();
    auto types_it       = get_types().begin();
    format app_fmt      = fmt(ctx, app, false, opts);
    format r            = format{format(what()), nest(indent, compose(line(), app_fmt))};
    format fun_type_fmt = fmt(ctx, *types_it, false, opts);
    r += compose(line(), format("Function type:"));
    r += nest(indent, compose(line(), fun_type_fmt));
    ++args_it;
    ++types_it;
    if (get_args().size() > 2)
        r += compose(line(), format("Arguments types:"));
    else
        r += compose(line(), format("Argument type:"));
    for (; args_it != args_end; ++args_it, ++types_it) {
        format arg_fmt    = fmt(ctx, *args_it, false, opts);
        format type_fmt   = fmt(ctx, *types_it, false, opts);
        r += nest(indent, compose(line(), group(format{arg_fmt, space(), colon(), nest(indent, format{line(), type_fmt})})));
    }
    r += pp_elaborator_state(fmt, get_elaborator(), opts);
    return r;
}
コード例 #2
0
format elaborator_exception::pp(formatter const & fmt, options const & opts) const {
    unsigned indent  = get_pp_indent(opts);
    format expr_fmt  = fmt(get_context(), get_expr(), false, opts);
    format r;
    r += format{format(what()), space(), format("at term")};
    r += nest(indent, compose(line(), expr_fmt));
    r += pp_elaborator_state(fmt, get_elaborator(), opts);
    return r;
}
コード例 #3
0
format pp_elaborator_state(formatter fmt, elaborator const & elb, options const & opts) {
    unsigned indent     = get_pp_indent(opts);
    format r;
    if (elb.has_constraints()) {
        format elb_fmt  = elb.pp(fmt, opts);
        r += compose(line(), format("Elaborator state"));
        r += nest(indent, compose(line(), elb_fmt));
    }
    return r;
}
コード例 #4
0
format pp(formatter fmt, context const & ctx, std::vector<expr> const & exprs, std::vector<expr> const & types, options const & opts) {
    unsigned indent = get_pp_indent(opts);
    lean_assert(exprs.size() == types.size());
    auto it1 = exprs.begin();
    auto it2 = types.begin();
    format r;
    for (; it1 != exprs.end(); ++it1, ++it2) {
        r += nest(indent, compose(line(), group(format{fmt(ctx, *it1, false, opts), space(), colon(),
                                                       nest(indent, format{line(), fmt(ctx, *it2, false, opts)})})));
    }
    return r;
}
コード例 #5
0
ファイル: builtin_cmds.cpp プロジェクト: silky/lean
environment check_cmd(parser & p) {
    expr e   = p.parse_expr();
    list<expr> ctx = locals_to_context(e, p);
    level_param_names ls = to_level_param_names(collect_univ_params(e));
    level_param_names new_ls;
    std::tie(e, new_ls) = p.elaborate_relaxed(e, ctx);
    auto tc = mk_type_checker_with_hints(p.env(), p.mk_ngen(), true);
    expr type = tc->check(e, append(ls, new_ls));
    auto reg              = p.regular_stream();
    formatter const & fmt = reg.get_formatter();
    options opts          = p.ios().get_options();
    unsigned indent       = get_pp_indent(opts);
    format r = group(format{fmt(e), space(), colon(), nest(indent, compose(line(), fmt(type)))});
    reg << mk_pair(r, opts) << endl;
    return p.env();
}
コード例 #6
0
format unification_type_mismatch_exception::pp(formatter const & fmt, options const & opts) const {
    unsigned indent     = get_pp_indent(opts);
    auto const & ctx    = get_context();
    expr const & e      = get_expr();
    expr const & p      = get_processed_expr();
    expr const & exp    = get_expected_type();
    expr const & given  = get_given_type();
    format r            = format{format(what()), nest(indent, compose(line(), fmt(ctx, e, false, opts)))};
    if (p != e) {
        r += compose(line(), format("Term after elaboration:"));
        r += nest(indent, compose(line(), fmt(ctx, p, false, opts)));
    }
    r += compose(line(), format("Expected type:"));
    r += nest(indent, compose(line(), fmt(ctx, exp, false, opts)));
    if (given) {
        r += compose(line(), format("Got:"));
        r += nest(indent, compose(line(), fmt(ctx, given, false, opts)));
    }
    r += pp_elaborator_state(fmt, get_elaborator(), opts);
    return r;
}
コード例 #7
0
ファイル: error_msgs.cpp プロジェクト: dumganhar/lean-osx
format pp_indent_expr(formatter const & fmt, environment const & env, options const & opts, expr const & e) {
    return nest(get_pp_indent(opts), compose(line(), fmt(env, e, opts)));
}
コード例 #8
0
ファイル: level.cpp プロジェクト: pazthor/lean
format pp(level const & lhs, level const & rhs, options const & opts) {
    return pp(lhs, rhs, get_pp_unicode(opts), get_pp_indent(opts));
}