Commit graph

6104 commits

Author SHA1 Message Date
Leonardo de Moura
f5de22ee36 chore: fix tests 2020-12-14 16:34:06 -08:00
Leonardo de Moura
abe7481453 feat: elaborate prio DSL 2020-12-14 16:25:10 -08:00
Leonardo de Moura
fcaf38d566 fix: handle prec DSL at infixl macro 2020-12-14 15:35:37 -08:00
Leonardo de Moura
9936040087 chore: fix test
TODO: add instance priorities.
2020-12-14 10:47:44 -08:00
Sebastian Ullrich
9a6af0f39f test: simplify beginEndAsMacro 2020-12-14 17:45:30 +01:00
Sebastian Ullrich
a914176897 test: fix... 2020-12-14 15:41:24 +01:00
Sebastian Ullrich
f641a660ce doc: include up-to-date begin-end macro code from test
@leodemoura: #include is pretty handy
2020-12-14 15:10:03 +01:00
Sebastian Ullrich
0316c872b9 feat: macro: use appropriate antiquotation kind dependent on bound syntax
/cc @leodemoura
2020-12-14 13:54:34 +01:00
Leonardo de Moura
bad714f5e9 feat: add deriving BEq 2020-12-13 16:13:27 -08:00
Leonardo de Moura
731ca49088 chore: cleanup 2020-12-13 15:51:34 -08:00
Leonardo de Moura
d6ba0592d1 chore: remove dead code 2020-12-13 15:50:08 -08:00
Leonardo de Moura
bbafaf8805 fix: Array.mk and Array.data externs 2020-12-13 11:10:01 -08:00
Leonardo de Moura
0bbc2ca884 feat: elaborate optDeriving 2020-12-13 09:05:03 -08:00
Leonardo de Moura
2a653743a1 test: simple test for deriving Inhabited
TODO: elaborate `optDeriving` suffix to `inductive/structure` commands
2020-12-12 18:58:56 -08:00
Leonardo de Moura
e9a1c3ac44 test: deriving experiment 2020-12-12 15:26:55 -08:00
Sebastian Ullrich
554d0b4d4c chore: adapt stdlib to new antiquotation splices 2020-12-12 17:20:03 +01:00
Sebastian Ullrich
8dfa588983 feat: introduce SepArray and use it for sepBy antiquotation splices 2020-12-12 16:02:15 +01:00
Sebastian Ullrich
9e06680541 chore: remove old antiquotations splice syntax 2020-12-12 14:57:14 +01:00
Sebastian Ullrich
a13f129312 feat: antiquotation suffix splices such as $x:k,*
/cc @leodemoura
2020-12-12 14:57:14 +01:00
Sebastian Ullrich
686a28fcc9 feat: allow do lifts inside unescaped antiquotations
/cc @leodemoura
2020-12-12 13:01:05 +01:00
Leonardo de Moura
ce1baa5f39 test: deriving command experiments 2020-12-11 18:34:17 -08:00
Sebastian Ullrich
bf63c4c0d0 feat: make sure dynamic quotations can only be used for parsers of arity 1 2020-12-11 21:34:30 +01:00
Sebastian Ullrich
591392840c fix: accept dynamic quotations in match 2020-12-11 21:34:30 +01:00
Leonardo de Moura
67379b359d fix: avoid macro scopes in error message 2020-12-11 11:23:44 -08:00
Leonardo de Moura
3682e3b993 chore: cleanup while/repeat example 2020-12-10 19:42:41 -08:00
Leonardo de Moura
f2ea45e68a feat: expose doSeq and termBeforeDo parsers
Users can use them to extend the `do` DSL.
2020-12-10 19:10:25 -08:00
Leonardo de Moura
c8298f4446 feat: support for big list literals
This encoding prevents stack overflows.
2020-12-10 17:19:46 -08:00
Leonardo de Moura
48af5627aa test: InductiveVal.isNested 2020-12-10 14:31:40 -08:00
Leonardo de Moura
9437f262af chore: fix test 2020-12-10 12:01:16 -08:00
Leonardo de Moura
ccabb59e88 chore: fix test 2020-12-10 11:50:12 -08:00
Leonardo de Moura
ffefd8db36 chore: remove weird syntax sugar from macro command
Before this commit,
```
macro term x:term : term => `($x)
```
would generate the notation
```
syntax "term" term : term
```
2020-12-10 08:09:47 -08:00
Leonardo de Moura
a10328e745 chore: simplify syntax patterns using $[...]? 2020-12-09 17:06:19 -08:00
Leonardo de Moura
71735faa33 fix: named argument that depends on missing explicit argument 2020-12-09 16:10:48 -08:00
Leonardo de Moura
63ab55289e chore: remove "liftable methods"
The new frontend "auto lifting" feature makes them obsolete.
2020-12-09 15:06:07 -08:00
Leonardo de Moura
e899b63def feat: suppress "synthetic sorry" at #check
@Kha The message `sorryAx ?m : ?m` is content free.
2020-12-09 14:17:16 -08:00
Leonardo de Moura
d4f48cbfa3 feat: improve error message "don't know how to synthesize implicit argument" 2020-12-09 14:09:30 -08:00
Leonardo de Moura
7a4b544b1c feat: improve application type mismatch error message
If the type error is at an implicit argument, we annotate
application with `pp.explicit := true`

Given the type incorrect definition
```
def f {a b c : α} : a = c :=
  Eq.trans (a := a) (b := b = c)
```
We now generate the error
```
error: application type mismatch
  @Eq.trans α a (b = c)
argument
  b = c
has type
  Prop
but is expected to have type
  α
```
@Kha Note that we only enable `pp.explicit := true` for the relevant
application. That is, we set `pp.explicit := false` for each children.

Unfortunately, there is a corner case.
```
set_option pp.explicit true
def f {a b c : α} : a = c :=
  Eq.trans (a := a) (b := b = c)
```
produces the error
```
error: application type mismatch
  @Eq.trans α a (b = c)
argument
  @Eq α b c
has type
  Prop
but is expected to have type
  α
```
The reset `pp.explicit := false` overwrote the user option.
I think the simplest solution is the following
1- The delaborator saves the initial set of Options `Init`
2- When it finds a node annotated with a `pp` options, it only
consider the option if it is not set by `Init`.

What do you think?
2020-12-09 13:58:08 -08:00
Sebastian Ullrich
a6fca7bced test: fix beginEndAsMacro output 2020-12-09 19:33:11 +01:00
Sebastian Ullrich
5673702687 doc: fix 2020-12-09 19:03:35 +01:00
Sebastian Ullrich
f50c8ff495 test: beginEndAsMacro: check error position 2020-12-09 18:13:25 +01:00
Sebastian Ullrich
d9246a8415 chore: adapt to new syntax syntax and introduce a few sepBy shorthands 2020-12-09 18:01:05 +01:00
Leonardo de Moura
f2339268b1 fix: adjust code to new match-compiler
In the new frontend,
```lean
@[macroInline] def or : Bool → Bool → Bool
  | true,  _ => true
  | false, b => b
```
is compiled as
```lean
def or (x y : Bool) : Bool :=
  or.match_1 _ x y (fun _ => true) (fun b => b)
```
Thus, the `[macroInline]` attribute does not guarantee that `y` is
evalutated only when `x` is `false`. The new definition does.

This issue was not exposed before because the compiler has an
optimization that float let-decls when they are used in a single
branch.

@Kha We have talked about removing `macroInline`, and defining
functions such as `or` as
```lean
@[inline] def or (x : Bool) (y : Unit -> Bool) : Bool :=
  match x with
  | true  => true
  | false => y ()
```
and define `x || y` as notation for `or x (fun _ => y)`.
I think this is the way to go for polymorphic operators such as `<|>`,
but I am not sure about `or`. New users will probably be puzzled by
it. In particular when they are writing proofs.
2020-12-08 13:46:00 -08:00
Sebastian Ullrich
00e167b2f0 feat: match_syntax ~> match 2020-12-08 17:20:36 +01:00
Sebastian Ullrich
6fc03d0f29 feat: quotation scopes in match_syntax 2020-12-08 17:13:32 +01:00
Sebastian Ullrich
b12be950bf feat: support complex antiquotations in antiquotation scopes 2020-12-08 17:13:32 +01:00
Leonardo de Moura
06ad52575a feat: force users to use discard when action result is not being bound and it is not PUnit
After this commit, we have to use an explicit `discard` in code such as
```
def g (x : Nat) : IO Nat := ...
def f (x : Nat) : IO Unit := do
  discard <| g x   -- type error without the `discard`
  IO.println x
```

Motivation: prevent users from making mistakes such as
```
def f (xs : Array Nat) : IO Unit := do
  xs.set! 0 1
  IO.println xs
```
when they meant to write
```
def f (xs : Array Nat) : IO Unit := do
  let xs := xs.set! 0 1
  IO.println xs
```
2020-12-08 06:14:48 -08:00
Leonardo de Moura
cbf2b6c0db feat: change synthinstance threshold
Before this commit, the threshold was the amount of "fuel".
Now, it is the maximum number of instances used to solve a TC problem.
We have two thresholds
- `maxInstSize`: default 128
- `maxCoeSize`: default 16. It is similar to `maxInstSize`, but used for automatic coercions.

cc @Kha
2020-12-07 10:45:08 -08:00
Leonardo de Moura
906cb81319 feat: improve inferAppType
See comment at `Expr.instantiateRevRange`
2020-12-06 19:01:23 -08:00
Leonardo de Moura
32325838a3 chore: fix test 2020-12-06 19:00:24 -08:00
Leonardo de Moura
91dec25a35 fix: bug at runST and runEST 2020-12-06 18:52:28 -08:00