Commit graph

2704 commits

Author SHA1 Message Date
Leonardo de Moura
5a7bf86a42 test: add test for buggy compiler step
Bug was fixed at da928f8c0
2020-08-26 08:34:35 -07:00
Leonardo de Moura
321719b300 feat: add MonadFinally 2020-08-25 17:58:35 -07:00
Leonardo de Moura
7888919aa9 test: MonadControl 2020-08-25 13:54:41 -07:00
Leonardo de Moura
b095f0652a fix: tryLiftAndCoe 2020-08-25 13:54:41 -07:00
Leonardo de Moura
e5b7daf9c2 refactor: make AppBuilder methods polymorphic 2020-08-24 18:23:34 -07:00
Leonardo de Moura
14f973d5a0 chore: fix tests 2020-08-24 17:59:11 -07:00
Leonardo de Moura
fab100abb4 chore: fix tests 2020-08-24 12:17:47 -07:00
Leonardo de Moura
060f7f0f04 chore: fix tests 2020-08-23 19:58:41 -07:00
Leonardo de Moura
77b9445544 feat: real ST monad
@Kha: the new `ST` (and `EST`) are escapable like the Haskell ST monad.
It makes `StateRefT` much more useful because we can now run it from pure
code.
2020-08-23 12:15:32 -07:00
Leonardo de Moura
5ffbada3df feat: add Lean.MonadEnv, Lean.MonadError, and Lean.MonadOptions
This is the first set of polymorphic methods. I will add more later,
and keep reducing code duplication.

cc @Kha
2020-08-22 16:00:43 -07:00
Leonardo de Moura
5cc173788e chore: remove ECoreM 2020-08-21 17:29:13 -07:00
Leonardo de Moura
f46c5d01b1 feat: uniform Exceptions 2020-08-21 17:02:21 -07:00
Leonardo de Moura
32a55d5b9c refactor: remove special support for IO errors
They are now just regular errors.
2020-08-21 11:55:58 -07:00
Leonardo de Moura
916b395d1b chore: cleanup 2020-08-21 09:29:09 -07:00
Sebastian Ullrich
786d90ac80 refactor: move parenthesizer and formatter into CoreM
/cc @leodemoura
2020-08-21 14:23:58 +02:00
Sebastian Ullrich
2a1d9b392f fix: test 2020-08-21 10:31:56 +02:00
Leonardo de Moura
d519a5d526 chore: use MetaM.toIO 2020-08-20 19:20:11 -07:00
Leonardo de Moura
cafb200296 chore: fix some tests 2020-08-20 19:13:47 -07:00
Leonardo de Moura
d6b96b4d8b chore: fix some tests 2020-08-20 18:36:29 -07:00
Leonardo de Moura
44f5182f76 chore: fix tests
We have removed `MetaIO`. We use use `CoreM` instead.
2020-08-20 15:56:29 -07:00
Sebastian Ullrich
2295749488 test: formatter no longer needs Lean.Parser imported 2020-08-20 15:55:41 +02:00
Leonardo de Moura
eec12232e3 chore: fix test
We would need to add the following instance to fix this example
```lean
instance ExceptT.monadIO {σ} (m : Type → Type) [Monad m] [MonadIO m] : MonadIO (ExceptT σ m) := {}
```
However, this instance may create problems for polymorphic functions on
`MonadIO m`. If `m` is of the form  `ExcepT Except1 ... EIO Exception2`,
then `finally` and `catch` is catching `Except1`. This is particularly
bad for code that uses `finally`.

Right now, we are not using monad stacks with multiple `ExceptT`s for
performance reasons, but we should have a solution for users.
2020-08-19 14:55:56 -07:00
Leonardo de Moura
75e6b5b379 fix: missing instance 2020-08-19 12:28:22 -07:00
Leonardo de Moura
61d1846334 feat: add adaptTheReader 2020-08-19 10:23:11 -07:00
Leonardo de Moura
e28f68936d feat: add MonadReaderOf 2020-08-19 10:14:36 -07:00
Sebastian Ullrich
eb5a171764 feat: adjust semantics to new syntax 2020-08-19 09:56:23 -07:00
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
Leonardo de Moura
f7f77241a1 chore: fix test 2020-08-17 17:14:28 -07:00
Leonardo de Moura
bb261c51a6 fix: isDefEqQuick 2020-08-15 13:24:43 -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
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
d7add53229 feat: add MonadExceptCore 2020-08-13 09:19:26 -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
Leonardo de Moura
43317d5598 fix: nullary minor premises must be thunks 2020-08-08 16:23:50 -07:00