Commit graph

49 commits

Author SHA1 Message Date
Leonardo de Moura
7b6d06df0d fix: remove bad instances
They are unnecessary, and were producing a very big search space in a
few examples.
2020-09-17 17:31:09 -07:00
Leonardo de Moura
5efa628e43 chore: split Lift.lean into MonadLift.lean, MonadFunctor.lean, and MonadRun.lean 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
31716731ba chore: cleanup 2020-08-25 15:06:12 -07:00
Leonardo de Moura
1103806ff4 refactor: HasMonadLift ==> MonadLift 2020-08-25 13:54:41 -07:00
Leonardo de Moura
b03cd748cf feat: add MonadControl 2020-08-25 13:54:41 -07:00
Leonardo de Moura
d85836a387 chore: mark TODO 2020-08-23 19:55:53 -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
37571edce5 fix: remove unnecessary dependencies 2020-08-22 15:15:10 -07:00
Leonardo de Moura
916b395d1b chore: cleanup 2020-08-21 09:29:09 -07:00
Leonardo de Moura
05a0e7f6d0 refactor: build all main monads on top of ECoreM 2020-08-20 18:36:04 -07:00
Leonardo de Moura
fad6235abb feat: give a name to EIO Empty
@Kha I am calling it `ST` for lack of a better name. It makes some
sense since only the `IO.Ref` operations are in `EIO Empty` :)
That being said, it may confuse Haskell users.

BTW, I had to give the name to avoid a nontermination in the TC
procedure when using
```lean
instance EIOEmpty.monadLift {ε} : HasMonadLift (EIO Empty) (EIO ε) :=
{ monadLift := fun α => fromEmptyEIO }
```
2020-08-20 15:47:27 -07:00
Leonardo de Moura
968457ac1c feat: make sure StateRefT can be used with any base EIO Exception 2020-08-20 13:11:12 -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
Leonardo de Moura
64f5ac37c1 fix: missing instance 2020-08-18 17:22:22 -07:00
Leonardo de Moura
4eef5a2fb6 fix: missing instance 2020-08-18 17:22:08 -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
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
1e496fb32d feat: helper instance 2020-08-18 13:26:14 -07:00
Leonardo de Moura
6c234daad7 chore: MonadExceptCore => MonadExceptOf 2020-08-13 09:28:23 -07:00
Leonardo de Moura
d7add53229 feat: add MonadExceptCore 2020-08-13 09:19:26 -07:00
Leonardo de Moura
447000a797 fix: >>= associativity 2020-08-03 14:00:19 -07:00
Sebastian Ullrich
719819bf49 fix: finally shouldn't call finalizer when finalizer throws 2020-07-10 07:42:26 -07:00
Leonardo de Moura
09eb27404f chore: remove <$ and $> notation
cc @Kha
2020-06-15 14:52:31 -07:00
Leonardo de Moura
bd58048449 chore: { <source> with ... } syntax 2020-05-20 15:08:43 -07:00
Leonardo de Moura
50990b99d6 chore: remove unnecessary annotations 2020-05-12 15:02:03 -07:00
Leonardo de Moura
33a10130cf chore: fix stdlib 2020-05-12 15:02:03 -07:00
Sebastian Ullrich
386c706f3e feat: basic parenthesizer 2020-05-04 14:28:36 -07:00
Sebastian Ullrich
8f67db0101 refactor: never implicitly ignore monadic results
Also change `do e; f` to desugar to `e *> f` so that it is affected as well
2020-04-23 11:09:59 -07:00
Daniel Selsam
fd61812b6e fix: wrong instance order for several instances 2020-04-08 16:55:48 -07:00
Leonardo de Moura
641cf90cc9 feat: add StateM.subsingleton 2020-03-02 08:37:55 -08:00
Leonardo de Moura
386e6179ff fix: missing [inline] and code idioms that produce low performance code 2020-02-17 19:06:42 -08:00
Leonardo de Moura
05fcb9b4d4 chore: remove MonadFail 2020-02-10 13:54:27 -08:00
Leonardo de Moura
31bb6a1dec feat: extend tryCoeAndLift
Add combined coe+lift case.
2020-02-03 14:30:13 -08:00
Leonardo de Moura
a134db5e07 feat: add Coe instances for monads 2020-02-03 11:41:00 -08:00
Leonardo de Moura
d8c738bef8 feat: elaborate do notation 2020-01-31 20:11:06 -08:00
Leonardo de Moura
9a505a0900 chore: name instance 2020-01-31 17:39:00 -08:00
Leonardo de Moura
018891b168 fix: subgoal order at hasMonadLiftTTrans 2020-01-30 09:58:21 -08:00
Leonardo de Moura
7809274c3a chore: Coe.lean ==> HasCoe.lean 2020-01-28 08:55:22 -08:00
Leonardo de Moura
22c42ec1d8 chore: remove unnecessary method 2020-01-28 08:24:35 -08:00
Leonardo de Moura
3264210d88 chore: helper functions 2020-01-03 12:24:14 -08:00
Leonardo de Moura
d37d02b512 fix: more general instance 2020-01-01 09:16:29 -08:00
Leonardo de Moura
90178dc3d9 feat: add syntaxNodeKindExtension
It contains all `SyntaxNodeKind`s registered in the system.
2019-12-31 16:36:50 -08:00
Leonardo de Moura
00cc28096c feat: add support for postponing elabTerm 2019-12-18 11:05:02 -08:00
Leonardo de Moura
c3005671f5 chore: avoid ^do ... 2019-12-11 06:19:12 -08:00
Leonardo de Moura
da73cbbdec chore: add abbreviations for monadLift 2019-12-09 15:40:38 -08:00
Leonardo de Moura
c445199747 chore: library/Init ==> src/Init
cc @Kha @dselsam @cipher1024
2019-11-22 06:06:05 -08:00