Commit graph

2936 commits

Author SHA1 Message Date
Leonardo de Moura
7c0b55ec6a chore: fix tests 2020-10-22 17:34:30 -07:00
Leonardo de Moura
de0eb8035f chore: fix test 2020-10-22 16:58:12 -07:00
Leonardo de Moura
85c955d77f feat: improve notation 2020-10-22 10:35:45 -07:00
Leonardo de Moura
34945dfc1c feat: elaborate notation 2020-10-22 10:20:23 -07:00
Leonardo de Moura
2041277cae fix: field default value with implicit type 2020-10-22 07:02:40 -07:00
Leonardo de Moura
6ca1768957 fix: optional := in the structure command 2020-10-22 04:39:20 -07:00
Sebastian Ullrich
4e74e36331 feat: run initializers on import
Also, refuse to evaluate an `[init]` decl in the same module (since we don't know whether the initialization is
backtrackable) and always use native symbol of a `[builtinInit]` decl
2020-10-22 11:59:55 +02:00
Leonardo de Moura
ea829b75c0 chore: remove coercions for old frontend 2020-10-21 17:37:35 -07:00
Leonardo de Moura
3e9c5e1653 chore: move to new frontend 2020-10-21 08:43:47 -07:00
Leonardo de Moura
35cf2f3d9f feat: use withSynthesize when elaborating the type of a type ascription 2020-10-20 15:12:54 -07:00
Leonardo de Moura
a052446414 feat: simplify decide! and nativeDecide! macros 2020-10-20 15:08:16 -07:00
Leonardo de Moura
fac2849e50 feat: forIn for PersistentArray 2020-10-20 09:33:50 -07:00
Leonardo de Moura
702ceb7a3f fix: return optional result
cc @Kha
2020-10-20 09:33:50 -07:00
Leonardo de Moura
c7efb1d37d fix: do notation else if
The following `do` block
```lean
if c_1 then
  action_1
else
  if cond_2 then
    action_2
  action_3
```
was being being parsed as
```lean
if c_1 then
  action_1
else if cond_2 then
  action_2
action_3
```

cc @Kha
2020-10-19 14:29:31 -07:00
Leonardo de Moura
437f4670ed fix: expand doIf notation before lifting nested methods 2020-10-19 11:32:51 -07:00
Leonardo de Moura
e54a207986 refactor: provide Options to lean_eval_const
add `ImportM` monad for `addImportedFn`

cc @Kha
2020-10-19 10:21:38 -07:00
Leonardo de Moura
7bfa39ae45 fix: for .. in .. do notation and universe constraints
We use `MProd` instead of `Prod` to group values when expanding the
`do` notation. `MProd` is a universe monomorphic product.
The motivation is to generate simpler universe constraints in code
that was not written by the user but generated by the `do` macro.
Note that we are not really restricting the macro power since the
`HasBind.bind` combinator already forces values computed by monadic
actions to be in the same universe.

The new test cannot be compiled without this modication.
2020-10-18 18:05:00 -07:00
Leonardo de Moura
45e1300414 fix: nested structural recursion 2020-10-18 10:38:51 -07:00
Leonardo de Moura
762073a7cb chore: update stage0 2020-10-18 08:22:30 -07:00
Leonardo de Moura
f5a16bc8f0 fix: better support for constraints of the form ?m a =?= ?m b 2020-10-17 16:29:27 -07:00
Leonardo de Moura
b2bc2d2775 feat: improve field notation argument search
@Kha the new test may look exoteric, but it reflects an actual
instance in our code base, and the old frontend supports it.
Not sure whether we should keep it or not.
2020-10-16 14:32:03 -07:00
Leonardo de Moura
8735820b49 fix: anonymous constructor too restrictive
We should support (recursive) inductive datatypes that have only one
constructor. We use this feature in the current `src/Lean` code base.
2020-10-16 07:58:47 -07:00
Leonardo de Moura
63e982768a feat: expand nested dos 2020-10-15 17:11:50 -07:00
Leonardo de Moura
827625a377 perf: add temporary hack for performance issue
The compiler frontend implemented in C++ is eagerly inlining local
functions. The new test would take an absurd amount of time without
the new hack.
We remove this hack when we re-implement the compiler frontend in Lean.
2020-10-15 13:37:29 -07:00
Leonardo de Moura
908e5f7acd fix: elabDiscrsWitMatchType 2020-10-15 11:00:33 -07:00
Leonardo de Moura
bdaf648667 fix: synthesizeSyntheticMVarsNoPostponing at elabMatch 2020-10-15 10:44:16 -07:00
Sebastian Ullrich
549912bbf4 test: Reformat.lean: make output test 2020-10-14 14:24:47 +02: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
d2e5c1c300 feat: improve dbgTrace! macro 2020-10-13 12:38:04 -07:00
Leonardo de Moura
d0bcb43c33 feat: improve Structural.lean 2020-10-12 16:58:30 -07:00
Leonardo de Moura
eacdb5ff83 feat: add Range notation 2020-10-12 11:50:13 -07:00
Leonardo de Moura
f57201d787 feat: add Repr and HasToString instances for PUnit and ULift 2020-10-12 11:01:59 -07:00
Leonardo de Moura
67e9c83f54 fix: for result type 2020-10-12 11:01:59 -07:00
Leonardo de Moura
dc670bfd5d fix: handle optParam at consumeImplicits
`consumeImplicits` is used during LVal resolution.
2020-10-11 15:26:10 -07:00
Leonardo de Moura
fda1d7b213 refactor: elabAppArgsAux
It also adds better support for opt/auto params and named arguments.
2020-10-11 15:08:12 -07:00
Leonardo de Moura
c5e3da89e8 fix: (try to) postpone when discriminant type is not known 2020-10-10 16:16:22 -07:00
Leonardo de Moura
7fec9587db fix: dollarProj notation bug 2020-10-10 13:38:07 -07:00
Leonardo de Moura
f84fa47566 fix: use resolveGlobalConstNoOverload at implementedBy attribute handler 2020-10-10 11:40:32 -07:00
Leonardo de Moura
f80345a6d4 chore: move tests to new frontend 2020-10-10 07:41:04 -07:00
Leonardo de Moura
fb2fea2744 fix: explicit syntax kind in macro_rules 2020-10-10 06:42:45 -07:00
Leonardo de Moura
6a808540d5 chore: remove macro println! 2020-10-09 20:53:44 -07:00
Leonardo de Moura
9538772c1c chore: do not use string interpolation by default at dbgTrace!
It is nice to be able to write `dbgTrace! x` instead of `dbgTrace! "{x}"`
2020-10-09 20:49:39 -07:00
Leonardo de Moura
be252743b3 feat: add string interpolation for MessageData 2020-10-09 20:43:26 -07:00
Leonardo de Moura
b4ef8de1a5 test: new frontend tests 2020-10-09 18:21:45 -07:00
Leonardo de Moura
bca81714fe feat: println! and dbgTrace! macros with string interpolation 2020-10-09 17:19:04 -07:00
Leonardo de Moura
ef27af9cf8 test: string interpolation 2020-10-09 17:02:12 -07:00
Leonardo de Moura
51dc10dd93 feat: array slicing notation 2020-10-09 16:40:18 -07:00
Leonardo de Moura
5a40d9eb13 feat: add Subarray 2020-10-09 16:06:24 -07:00
Leonardo de Moura
749e2063cf feat: add interpolated string for toString 2020-10-09 14:38:24 -07:00
Leonardo de Moura
6020e6682a feat: process interpolatedStr in the elaborator 2020-10-09 14:18:45 -07:00