Commit graph

115 commits

Author SHA1 Message Date
Leonardo de Moura
81ba5485dd refactor: StateCpsT
Define `run` and `run'` using `runK`.
Write auxiliary simp lemmas using `runK`.
2021-03-02 06:22:22 -08:00
Leonardo de Moura
bbf158005f chore: make sure it matches the paper 2021-02-28 17:57:00 -08:00
Leonardo de Moura
35e1f5ad97 refactor: Foldable => Traversable 2021-02-28 16:11:20 -08:00
Leonardo de Moura
ef4d5950ae feat: add Foldable typeclass
We use it in the "`do` unchained" paper.
It will eventually replace `ForIn`.
2021-02-28 09:00:52 -08:00
Leonardo de Moura
f9483a8068 feat: add ExceptCpsT.runCatch 2021-02-27 18:59:58 -08:00
Leonardo de Moura
481189bcf4 feat: add ExceptCpsT 2021-02-27 18:44:24 -08:00
Leonardo de Moura
238f96b616 feat: add StateCpsT 2021-02-27 18:21:19 -08:00
Leonardo de Moura
6a6f68f6cc feat: missing lemmas 2021-02-27 10:42:30 -08:00
Sebastian Ullrich
8b20a939aa fix: Reader 2021-02-26 14:58:09 +01:00
Leonardo de Moura
d3a914c1ff chore: cleanup 2021-02-23 12:52:14 -08:00
Leonardo de Moura
162062b3de feat: improve Lawful.lean 2021-02-23 12:38:00 -08:00
Leonardo de Moura
98348dfe7f feat: add ExceptT.run_bind_lift and ExceptT.bind_throw
Remove `[simp]` attribute from `ExceptT.run_bind`
2021-02-23 08:17:11 -08:00
Leonardo de Moura
d0574d8eb1 feat: add LawfulMonad for StateT 2021-02-21 10:52:53 -08:00
Leonardo de Moura
ae48feeb07 feat: add LawfulMonad for ReaderT 2021-02-21 08:27:59 -08:00
Leonardo de Moura
d77f335ff0 feat: add LawfulMonad instance for ExceptT 2021-02-20 17:01:27 -08:00
Leonardo de Moura
caf54d78e2 feat: add Control/Lawful.lean 2021-02-20 09:37:43 -08:00
Sebastian Ullrich
187a614575 chore: make tryFinally a def 2021-02-17 12:04:20 +01:00
Leonardo de Moura
f57c184dbd chore: remove = true old workarounds
@Kha The old `= true` workarounds are not needed anymore, they were
due to another issue and are not related to yesterday's issue.
That is, the one exposed by the `ForIn` typeclass.
2021-02-05 13:48:03 -08:00
Sebastian Ullrich
0c91b3769e chore: replace variables in src/ 2021-01-22 14:36:05 +01:00
Leonardo de Moura
bfc1a16c02 chore: adjust instance param order 2021-01-13 18:31:41 -08:00
Leonardo de Moura
5f6e66a53f refactor: Repr
Modifications:
- Result type is `Format`
- It takes the context precedence like Haskell `Show`
2020-12-18 11:21:30 -08:00
Leonardo de Moura
2e11c3bdff feat: dependencies 2020-12-18 11:21:30 -08:00
Leonardo de Moura
5249fdc24d chore: cleanup and style 2020-12-12 10:36:26 -08:00
Leonardo de Moura
ae5aa51712 chore: add explicit discard 2020-12-08 06:18:18 -08:00
Sebastian Ullrich
1f9e8bc93d fix: <&> 2020-12-01 11:57:20 -08:00
Leonardo de Moura
1e84fa1eed refactor: more general OfNat, remove One and Zero classes 2020-12-01 07:49:52 -08:00
Leonardo de Moura
d734a2605b chore: adjust stdlib 2020-11-29 17:01:56 -08:00
Leonardo de Moura
16003871e4 feat: add helper instance 2020-11-28 19:01:54 -08:00
Leonardo de Moura
0869f38de4 chore: update structure, class, inductive 2020-11-27 15:09:30 -08:00
Leonardo de Moura
c0db9f1e0c chore: adjust stdlib to recent changes 2020-11-27 12:26:07 -08:00
Leonardo de Moura
f456e006dc chore: test instance ... where 2020-11-23 18:24:23 -08:00
Leonardo de Moura
be812081f4 chore: using "unbound implicit locals" 2020-11-23 13:09:02 -08:00
Leonardo de Moura
e6215f7282 chore: remove some unnecessary commas 2020-11-20 15:47:27 -08:00
Leonardo de Moura
304c80d610 feat: use <| 2020-11-19 09:03:38 -08:00
Leonardo de Moura
91dca53274 refactor: remove MonadIO
There is no reason for having `MonadIO` anymore. The `MonadLift` type
class is well behaved in the new frontend, the `MonadFinally` solves
the problem at monad stacks such as `ExcepT e IO`.

This commit also changes the type of the IO printing functions.
For example, the type of `IO.println` was
```
def IO.println {m} [MonadIO m] {α} [ToString α] (s : α) : m Unit
```
and now it is just
```
def IO.println {α} [ToString α] (s : α) : IO Unit
```
We rely on the new frontend auto-lifting feature.
That is, if there is an instance `[MonadLiftT IO m]`, then
a term of type `IO a` is automatically coerced to `m a`

We also want a simpler `IO.println` for writing tests.
For example,
```
```
doesn't work because there isn't sufficient information for inferring
the parameter `m` in the previous `IO.println`.
The shortest workaround looked very weird
```
```

I considered adding `IO` as a default value for `m` when we have
`MonadIO m`, as we use `Nat` as the default for `ofNat a`, but it felt
like uncessary complexity.

@Kha The commit seems to work well. The auto-lifting featuring has
been working great for me. There is still room for improvement.
For example, given `MonadLiftT m n`, it doesn't automatically lift
`a -> m b` into `a -> n b`. So, code such as
`foo >>= IO.println`
had to be rewritten as
`foo >>= fun x => IO.println x`
I will add this feature later.
If you have time, please try to play with this feature and figure out
if it is stable enough for making it the default.
That is, if it roboust enough, we can stop using the following idiom
for writing functions that can be lifted automatically.
```
def instantiateLevelMVarsImp (u : Level) : MetaM Level :=
  ...

def instantiateLevelMVars {m} [MonadLiftT MetaM m] (u : Level) : m Level :=
  liftMetaM $ instantiateLevelMVarsImp u
```
I think we only need this idiom when using `MonadControlT` which is
not as common as `MonadLiftT`.
2020-11-18 18:47:22 -08:00
Leonardo de Moura
dbf99a17b6 chore: define notation using infix commands 2020-11-11 08:26:12 -08:00
Leonardo de Moura
ccf69ae69d fix: missing file 2020-11-11 05:56:47 -08:00
Leonardo de Moura
6ab0be952c chore: merge src/Control files
Some of them were almost empty after the refactoring.
2020-11-10 18:47:23 -08:00
Leonardo de Moura
a8c791ecae chore: remove dead files and functions
Remove obsolete combinators: `whenM`, `unlessM`, and `condM`

cc @Kha
2020-11-10 18:37:15 -08:00
Leonardo de Moura
cca3bad0bb feat: add Prelude.lean
`Prelude.lean` has no dependencies, and
at the end of `Prelude`, the `syntax` and `macro` commands are operational.
2020-11-10 18:08:18 -08:00
Leonardo de Moura
bcae20381f chore: naming convention 2020-10-31 19:19:18 -07:00
Leonardo de Moura
898a08a0c1 chore: avoid Has prefix in type classes
closes #203
2020-10-27 18:29:19 -07:00
Leonardo de Moura
97c93ec557 chore: prepare to rename 2020-10-27 18:09:03 -07:00
Leonardo de Moura
5fed774461 chore: HasRepr ==> Repr 2020-10-27 16:15:10 -07:00
Leonardo de Moura
10c32fcf94 chore: HasToString => ToString 2020-10-27 16:11:48 -07:00
Leonardo de Moura
633578cfaf chore: use StateRefT macro 2020-10-27 13:05:12 -07:00
Leonardo de Moura
13c2a8ff51 chore: remove #lang lean4 header 2020-10-25 09:54:07 -07:00
Leonardo de Moura
78c05e8f46 chore: move to new frontend 2020-10-23 16:13:55 -07:00
Leonardo de Moura
5c58d77836 chore: move to new frontend 2020-10-23 12:53:19 -07:00
Leonardo de Moura
7030dc91f2 chore: move to new frontend 2020-10-23 12:50:03 -07:00