Commit graph

87 commits

Author SHA1 Message Date
Leonardo de Moura
665c3ed2f7 chore: cleanup 2020-10-31 19:19:18 -07:00
Leonardo de Moura
8c9f148e2f chore: use new termFor, termReturn, termTry, and tryUnless 2020-10-31 19:19:18 -07:00
Leonardo de Moura
88fb6acae3 chore: remove clutter 2020-10-28 13:29:17 -07:00
Leonardo de Moura
97c93ec557 chore: prepare to rename 2020-10-27 18:09:03 -07:00
Leonardo de Moura
573ca7dcad chore: remove workarounds 2020-10-27 13:05:13 -07:00
Leonardo de Moura
633578cfaf chore: use StateRefT macro 2020-10-27 13:05:12 -07:00
Leonardo de Moura
13c2a8ff51 chore: remove #lang lean4 header 2020-10-25 09:54:07 -07:00
Leonardo de Moura
3de97ddc27 feat: run linters in the new frontend 2020-10-23 14:04:28 -07:00
Leonardo de Moura
fa3c32d3b1 chore: remove adaptExcept 2020-10-22 16:56:23 -07:00
Leonardo de Moura
82ee2e361b chore: cleanup 2020-10-21 18:43:47 -07:00
Leonardo de Moura
1495f403a1 chore: use builtin_initialize instead of initialize at src/Lean 2020-10-19 15:17:02 -07:00
Leonardo de Moura
9d36d91b84 chore: add Elab.command trace class 2020-10-18 16:35:08 -07:00
Leonardo de Moura
b72ebe87bd chore: move to new frontend
@Kha All files at `src/Lean/Elab` are now being compiled with the new
frontend. We can finally claim our elaborator can elaborate itself :)
It is 22% of our code base.
2020-10-16 12:34:07 -07:00
Leonardo de Moura
65abb119f5 chore: move to new frontend 2020-10-16 11:57:19 -07:00
Leonardo de Moura
1afc33278c refactor: use StateRefT at Frontend 2020-10-14 13:20:01 -07:00
Leonardo de Moura
9af0a0e18b feat: add withReader method
@Kha `withReader` is a well-behaved version of `adaptReader`. `adaptReader` is
too general, and it often produces counterintuitive elaboration
errors.

Here are two super annoying issues I hit all the time:
1- `adaptReader` + polymorphic code
```
def ex1 : ReaderT Nat IO Unit :=
adaptReader (fun x => x + 1) $
  IO.println "foo" -- 3 Errors here failed to synthesize `Monad ?m` and  `MonadIO ?m`, and don't know how to synthesize `Type → Type`
```

2- `adaptReader` and notation that requires the expected type
```
structure Context :=
(x y : Nat)

def ex2 : ReaderT Context IO Nat :=
adaptReader (fun s => { s with x := 10 }) $ -- Error at the structure instance
  ...
```
In the example above, I have to write `fun (s : Context) => ...` to
fix the problem.

The two problems above happen in the old and new frontends. However,
there is a new problem specific for the new frontend. In the new
frontend, a `do` is only elaborated when the expected type is known.
So, `adaptReader (fun ctx => ...) do ...` seldom works :(

As I said above, the issue is that `adaptReader` is too general. Its
type is
```
  {ρ ρ' : Type u_1} → {m m' : Type u_1 → Type u_2} → [MonadReaderAdapter ρ ρ' m m'] → {α : Type u_1} → (ρ' → ρ) → m α → m' α
```

`withReader` is a simpler version of `adaptReader`
```
withReader : {ρ : Type u_1} → {m : Type u_1 → Type u_2} → [MonadWithReader ρ m] → {α : Type u_1} → (ρ → ρ) → m α → m α
```
It doesn't have any of the problems above. Moreover, I managed to replace
every single instance of `adaptReader` with `withReader` at the stdlib
and tests. We don't need the `adaptReader` generality.
2020-10-13 15:00:17 -07:00
Leonardo de Moura
069faf0a0a chore: move ResolveName to new frontend 2020-10-10 13:03:46 -07:00
Leonardo de Moura
fa6b7b6393 feat: add MonadResolveName type class
`AttrM` can now resolve names.
2020-10-10 11:33:52 -07:00
Leonardo de Moura
eacf3ed6c7 refactor: move ResolveName to Lean directory 2020-10-10 11:07:14 -07:00
Leonardo de Moura
b93c5b47ec chore: remove Alias.lean 2020-10-10 11:00:16 -07:00
Leonardo de Moura
fa338c1885 refactor: move resolveGlobalName to Lean namespace 2020-10-10 10:58:44 -07:00
Leonardo de Moura
82e11c401d fix: #eval was not capturing dbgTrace! output in pure code
In the following example, the output produced by `dbgTrace!` was not
being captured. It could break the lean server. At least, it broke the lean4-mode.
```lean
def f (x : Nat) : Nat :=
dbgTrace! ">>> " ++ toString x;
x + 1

eval f 10
```

cc @Kha
2020-10-05 10:22:04 -07:00
Sebastian Ullrich
19dcbdcec9 fix: do not format Syntax in Messages eagerly 2020-09-29 07:59:22 -07:00
Leonardo de Moura
44129ce461 refactor: move withoutModifyingEnv to MonadEnv 2020-09-25 06:48:51 -07:00
Leonardo de Moura
6ed69525ad chore: move functions to Environment namespace 2020-09-20 08:28:43 -07:00
Leonardo de Moura
ac2a9539f9 fix: old&new frontend interference
The new test was not working because new frontend was using old
frontend function.
2020-09-20 08:25:45 -07:00
Leonardo de Moura
4786cb12b5 fix: unknown namespace error message 2020-09-20 07:10:23 -07:00
Leonardo de Moura
02e6f019c4 refactor: move nextMacroScope to Core.State
@Kha We now can create scoped user-facing names at `CoreM` and `MetaM`
methods.
2020-09-18 12:00:24 -07:00
Leonardo de Moura
0e8f8117a1 refactor: simpler mechanism for never backtracking traces
We do backtrack messages but not traces.

cc @Kha
2020-09-18 10:31:42 -07:00
Leonardo de Moura
a28679358e refactor: remove MonadError 2020-09-18 09:58:13 -07:00
Leonardo de Moura
9f5e63cd3c feat: add option pp.macroStack
@Kha I set it to `false` by default.
2020-09-16 15:29:28 -07:00
Leonardo de Moura
965a989dc2 fix: must log at evalCommand
Some macros expand a command into multiple commands. We should not
interrupt the elaboration of the command sequence when one fails.
2020-09-16 14:55:58 -07:00
Leonardo de Moura
d81f1c585b fix: incorrect default configuration 2020-09-16 08:26:41 -07:00
Leonardo de Moura
b52ce76222 feat: display uncaught internal exceptions 2020-09-16 08:23:12 -07:00
Leonardo de Moura
0abca5475f refactor: move ppExpr to IO
@Kha I am also tracking `currNamespace` and `openDecls`.

BTW, I also tried an experiment where I added `currNamespace` and
`openDecls` to `Meta.Context`, but it looked weird. This information
is only needed in the elaborator and pretty printer.
The `PPContext` object should contain everything you need. You
can put `currNamespace` and `openDecls` in the `Delaborator.Context`.
2020-09-15 18:48:21 -07:00
Leonardo de Moura
7c0216595e fix: remove duplicate error messages due to variable(s)
In Lean4, we re-elaborate `variable`(s) for each command, but we don't
want the error messages due to `variable` to appear in the log
multiple times.
2020-09-14 12:44:25 -07:00
Leonardo de Moura
cc520d422c fix: ensure no unassigned mvars at #eval 2020-09-12 07:18:43 -07:00
Leonardo de Moura
a8df621683 fix: bug at elabEvalUnsafe
It was forgetting the the updates performed by `MetaHasEval`.
Wow, I wasted a lot of time on this bug.
2020-09-10 19:33:52 -07:00
Leonardo de Moura
264ce93bc8 chore: simplify elabEval
`TermElab` is now on top of `IO`
2020-09-10 15:03:45 -07:00
Leonardo de Moura
9b788db91f feat: compute level parameters for mutually recursive definitions 2020-09-05 07:34:26 -07:00
Leonardo de Moura
907a202961 feat: expand in command macro 2020-09-02 10:04:58 -07:00
Leonardo de Moura
5ced8867b0 feat: anonymous instances and support for all kinds of definition at mutual 2020-09-01 17:00:00 -07:00
Leonardo de Moura
d74551b19e feat: elaborate header of mutually recursive definitions 2020-09-01 16:13:04 -07:00
Leonardo de Moura
b9d50d2adf refactor: expandDeclId 2020-09-01 13:12:36 -07:00
Leonardo de Moura
5e5b75af61 chore: remove withDeclId 2020-09-01 13:04:08 -07:00
Leonardo de Moura
9f16d01058 refactor: reduce DeclModifiers dependencies 2020-08-31 10:12:06 -07:00
Leonardo de Moura
e5c35d3a4e feat: add AddMessageDataContext 2020-08-28 18:05:42 -07:00
Leonardo de Moura
39d456cb09 feat: add polymorphic trace and logTrace
This commit also makes sure we always use `withContext` when logging.
2020-08-28 16:49:24 -07:00
Leonardo de Moura
65f1c3fe65 chore: simplify MonadMacroAdapter 2020-08-28 16:24:06 -07:00
Leonardo de Moura
cc47705691 chore: remove import Init.* 2020-08-28 15:39:08 -07:00