Commit graph

5419 commits

Author SHA1 Message Date
Leonardo de Moura
58c4d8bfc0 refactor: add MonadStateOf
@Kha I tried to remove `MonadExceptOf` by adding `HasThrow` and
`HasCatch`, but this change impacts our ability to define polymorphic
methods such as `finally` which is parametrized by `[MonadExcept]`.
If we remove the `outParam` from `[MonadExcept]`, then we will need to
know the exception at `finally`, or add two instances `[HasCatch]` and
`[HasThrow]`. So, it seems it is more convenient to have
`[MonadExceptOf]` and `[MonadExcept]`. Thus, I applied this approach
to `[MonadState]`
2020-08-18 16:35:33 -07:00
Leonardo de Moura
9519479726 chore: fix test 2020-08-18 15:19:22 -07:00
Leonardo de Moura
647b917b49 test: HasGetAt helper class example 2020-08-18 15:16:02 -07:00
Leonardo de Moura
5605735137 feat: remove outparam from MonadState
We add helper classes with `outParam`.

@Kha This is similar to the `MonadExceptOf` modification.
Motivation: the new `StateRefT` (state monad implemented using
`IO.Ref`) makes is it quite cheap to have multiple states on the
stack. But, we need a mechanism for accessing the different states in
a convenient way.
Note that, I did not add a `MonadStateOf` class, but helper classes
such as `HasGet` which uses `outParam`. I will do the same for `MonadExcept`.

Summary:
- `get` gets the state on the top of the Monad stack
- `getThe σ` gets the state with type `σ`
- `modify f` modifies the state on the top of the Monad stack.
   We use `modify fun s => { s with ... }` quite often, and we cannot
   infer type of `s` here.
- `modifyThe σ f` allows us to select which state on the stack we are modifying.
- I didn't add `setThe`, since we usually can infer the state type at
  `set s`. In the whole codebase, we have only one instance where this
  is not true.
2020-08-18 15:15:31 -07:00
Leonardo de Moura
f01d45a6c1 feat: add StateRef 2020-08-18 13:54:51 -07:00
Leonardo de Moura
b142c608fe feat: add CoreM 2020-08-18 09:45:16 -07:00
Sebastian Ullrich
5e48d2bb7d chore: update cross benches 2020-08-18 11:44:29 +02:00
Leonardo de Moura
d059d28c22 fix: anonymous constructor elaborator 2020-08-17 17:32:11 -07:00
Leonardo de Moura
0cda65057e fix: addCtorFields 2020-08-17 17:25:42 -07:00
Leonardo de Moura
f7f77241a1 chore: fix test 2020-08-17 17:14:28 -07:00
Leonardo de Moura
81a19c8554 feat: structure instances with .. in patterns 2020-08-17 16:23:49 -07:00
Leonardo de Moura
9b085b97c4 feat: let+equations macro 2020-08-17 10:15:43 -07:00
Leonardo de Moura
f335cb3304 test: let+pattern 2020-08-17 09:28:25 -07:00
Leonardo de Moura
3342ba08d2 feat: implement let elaborators without using match_syntax
@Kha I had to do this because of the `ident` vs `Term.id` recurrent
issue. `match_syntax` fails if a `Term.id` is used at `Term.letIdDecl`
where an `ident` is expected.
We should try to remove `Term.id` in the future.
2020-08-17 09:27:54 -07:00
Leonardo de Moura
5d945dba2d test: match-expression 2020-08-16 15:50:22 -07:00
Leonardo de Moura
a97f8cb8e4 fix: nontermination at DepElim 2020-08-16 11:07:44 -07:00
Leonardo de Moura
58f4b280ca feat: elaborate nomatch 2020-08-16 08:26:04 -07:00
Leonardo de Moura
b616e8d07a test: do issue
This is the example triggered a panic message in the new frontend when
we were encoding `do a; b` as `a *> b`.
See 7cdf917c9
2020-08-15 16:07:01 -07:00
Leonardo de Moura
4f145c744e test: match-expr 2020-08-15 16:03:31 -07:00
Leonardo de Moura
e32ebc62c0 fix: tryPostponeIfMVar
Must not postpone if there is a term `t` (which is not a metavariable)
assigned to the metavariable `e.getAppFn`.
2020-08-15 14:36:16 -07:00
Leonardo de Moura
2295c315aa feat: add elabTermEnsuringType
This commit also fixes a match-expression error location issue.
2020-08-15 13:49:10 -07:00
Leonardo de Moura
e9748dd0f9 test: match equality proofs 2020-08-15 13:35:16 -07:00
Leonardo de Moura
bb261c51a6 fix: isDefEqQuick 2020-08-15 13:24:43 -07:00
Leonardo de Moura
34d9879061 test: add new tests 2020-08-15 13:14:16 -07:00
Leonardo de Moura
0be9516bd8 fix: instantiate metavariables in alternative local decls 2020-08-15 08:18:00 -07:00
Leonardo de Moura
7eed45dd45 fix: generalize isNatValueTransition 2020-08-15 07:59:31 -07:00
Leonardo de Moura
4223bdf8aa feat: add expandNatValuePattern 2020-08-15 07:26:22 -07:00
Leonardo de Moura
5d56cc5505 refactor: DepElim
We go back to the original approach where we pattern matching
alternative variables as `FVar`s.
We fix the original problem we had by implementing a simple
unification procedure for alternative `FVar`s.
2020-08-14 19:03:22 -07:00
Leonardo de Moura
00d46e4a7d chore: preparing to refactor DepElim 2020-08-14 19:02:20 -07:00
Leonardo de Moura
b4b60dc326 feat: add List.filterMapM 2020-08-14 10:50:48 -07:00
Leonardo de Moura
bd8e2d305f feat: add Array.filterMap 2020-08-14 10:50:48 -07:00
Sebastian Ullrich
64631609cc feat: use [categoryParenthesizer] to parenthesize syntax parsers correctly 2020-08-14 14:42:44 +02:00
Leonardo de Moura
94689ca91f chore: fix test 2020-08-13 16:55:03 -07:00
Leonardo de Moura
69ee44d68e feat: match-expressions showing signs of life 2020-08-13 16:51:31 -07:00
Leonardo de Moura
a670de93cd chore: fix test 2020-08-13 14:59:37 -07:00
Leonardo de Moura
08f1c2310b chore: enforce naming convention 2020-08-13 14:09:00 -07:00
Leonardo de Moura
5b1b11ffe0 feat: add isCharLit 2020-08-13 13:15:15 -07:00
Leonardo de Moura
145a3dddca chore: remove ref from patterns
We don't use them to report errors. We only need `ref` at `Alt`
2020-08-13 12:31:32 -07:00
Leonardo de Moura
a6b22728ca chore: reduce stack space requirements in test 2020-08-13 12:13:38 -07:00
Leonardo de Moura
5ba9aad7a3 refactor: eliminate ref plumbing 2020-08-13 10:37:53 -07:00
Leonardo de Moura
d7add53229 feat: add MonadExceptCore 2020-08-13 09:19:26 -07:00
Leonardo de Moura
bd7a7ed623 refactor: reduce ref plumbing
TODO: reduce `ref` plumbing at `CommandElabM`
2020-08-12 20:23:02 -07:00
Leonardo de Moura
f924b481c2 chore: simplify mkElim interface 2020-08-12 16:34:43 -07:00
Sebastian Ullrich
1972e04302 test: parenthesizer no longer dependent on importing Lean 2020-08-12 09:15:59 -07:00
Sebastian Ullrich
1f4cc130b7 feat: precompile parenthesizers instead of interpreting them 2020-08-12 09:15:59 -07:00
Sebastian Ullrich
b2714d36ef fix: String: take/drop characters, not bytes 2020-08-11 18:24:47 -07:00
Leonardo de Moura
d1d91b3a50 chore: fix test 2020-08-10 11:19:05 -07:00
Leonardo de Moura
e59735bde9 chore: fix test
@Kha the tests `Reparen.lean` and `Reformat.lean` are still
broken. Could you please take a look?
They broke because I changed the `match` syntax at 3ce794c58.
2020-08-10 10:20:57 -07:00
Leonardo de Moura
43317d5598 fix: nullary minor premises must be thunks 2020-08-08 16:23:50 -07:00
Leonardo de Moura
d2206dcab2 feat: as-patterns x@pattern 2020-08-08 16:12:44 -07:00