Commit graph

99 commits

Author SHA1 Message Date
Leonardo de Moura
b6a1914299 chore: remove $. notation
It has been replaced by `|>.`
2020-11-19 08:47:35 -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
f9194737f0 chore: fix tests 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
10c32fcf94 chore: HasToString => ToString 2020-10-27 16:11:48 -07:00
Leonardo de Moura
ea829b75c0 chore: remove coercions for old frontend 2020-10-21 17:37:35 -07:00
Leonardo de Moura
49c5c5c08a fix: horrible error message due to constApprox := true
The new test `typeMismatch.lean` contains two examples where the error
message was dreadful.
2020-09-29 07:54:48 -07:00
Leonardo de Moura
a0a724ddbd fix: tests and elabDo 2020-09-26 19:12:01 -07:00
Leonardo de Moura
0abca5475f refactor: move ppExpr to IO
@Kha I am also tracking `currNamespace` and `openDecls`.

BTW, I also tried an experiment where I added `currNamespace` and
`openDecls` to `Meta.Context`, but it looked weird. This information
is only needed in the elaborator and pretty printer.
The `PPContext` object should contain everything you need. You
can put `currNamespace` and `openDecls` in the `Delaborator.Context`.
2020-09-15 18:48:21 -07:00
Leonardo de Moura
b02cda0408 chore: move more tests to new frontend 2020-09-11 15:31:14 -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
44f5182f76 chore: fix tests
We have removed `MetaIO`. We use use `CoreM` instead.
2020-08-20 15:56:29 -07:00
Leonardo de Moura
64bcb71b7a chore: fix test 2020-07-14 16:44:02 -07:00
Leonardo de Moura
1612097788 chore: move HashMap and HashSet to Std 2020-06-25 12:46:56 -07:00
Leonardo de Moura
f838b80e03 fix: elaboration functions for parser! and tparser! 2020-06-10 16:42:42 -07:00
Leonardo de Moura
b3a8d417b2 chore: fix test 2020-06-08 16:12:05 -07:00
Leonardo de Moura
9c0bd9dd41 chore: fix tests 2020-05-26 15:05:00 -07:00
Leonardo de Moura
ebc0663b3f chore: fix tests 2020-05-12 15:02:03 -07:00
Leonardo de Moura
21618361b7 refactor: remove ParserKind 2020-01-30 20:56:46 -08:00
Leonardo de Moura
b00c04c491 fix: missing ensureHasType 2020-01-29 16:29:48 -08:00
Leonardo de Moura
bb1a90b24d chore: fix tests 2020-01-28 10:34:27 -08:00
Leonardo de Moura
9f14a45cef fix: Level parser 2020-01-14 18:43:42 -08:00
Leonardo de Moura
f83678f19b chore: fix test 2020-01-11 13:55:31 -08:00
Leonardo de Moura
733ea89000 feat: improve application type mismatch error message 2020-01-09 16:41:27 -08:00
Leonardo de Moura
65370e9322 chore: restore disabled tests 2020-01-08 21:24:01 -08:00
Leonardo de Moura
760f8aa013 chore: fix tests 2020-01-08 21:09:17 -08:00
Leonardo de Moura
9ebf21f2d5 fix: elabConstant 2020-01-08 15:06:18 -08:00
Leonardo de Moura
3de7d6d5c3 fix: remove mvarTypeNotWellFormedInSmallerLCtx
We use `check` recursively instead of `isWellFormed`.

@kha This was the last bug for the repro
```
```
This example works now, but I am sure there are many other bugs.
2020-01-07 16:56:10 -08:00
Leonardo de Moura
2ce2610c0a feat: add compileDecl
cc @kha
2020-01-07 16:38:41 -08:00
Leonardo de Moura
24f1479758 chore: remove workaround 2020-01-06 16:44:08 -08:00
Leonardo de Moura
20c0a63908 feat: add support for optParam 2020-01-06 16:41:48 -08:00
Leonardo de Moura
bccaaa7af0 fix: bug at lit_type binding
cc @kha
2020-01-06 15:44:38 -08:00
Leonardo de Moura
865ef32e91 feat: add parser! and tparser! elaborators
@Kha It is not convenient to use because
1- Coercions have not been implemented
2- Autoparams have not been implemented
3- There is bug the `Expr.lit` type checker
4- The new frontend uses a different mechanism for `export`. So,
`export`s in imported files compiled with the old frontend do not work.

I am working on these issues.
2020-01-06 15:10:35 -08:00
Leonardo de Moura
911e9535b9 feat: elabDefLike 2020-01-06 12:10:08 -08:00
Leonardo de Moura
5be180910f test: add applyAttributes test 2020-01-05 16:27:22 -08:00
Leonardo de Moura
0231841984 feat: applyAttributes 2020-01-05 16:22:46 -08:00
Leonardo de Moura
bc7455e04e refactor: CommandElabM and FrontendM in IO 2020-01-03 18:15:45 -08:00
Leonardo de Moura
e949a052ba feat: elaborate where 2020-01-02 15:01:26 -08:00
Leonardo de Moura
16aff9a182 feat: elaborate have 2020-01-02 14:16:20 -08:00
Leonardo de Moura
9f69991d80 feat: elaborate show notation 2020-01-02 13:30:11 -08:00
Leonardo de Moura
a3675b99e6 feat: add parameter postponeOnError : Bool to synthesizeSyntheticMVarsStep
@Kha: I implemented the option 2 I described on Zulip.
2020-01-02 13:13:58 -08:00
Leonardo de Moura
db96b08257 feat: elaborate anonymous constructor 2020-01-02 10:41:04 -08:00
Leonardo de Moura
0ffd1526bd feat: elaborate subtype 2020-01-02 10:12:19 -08:00
Leonardo de Moura
8f805f5d2f feat: elaborate if-then-else 2020-01-01 16:12:26 -08:00
Leonardo de Moura
cbe65a068e fix: addLValArg 2020-01-01 16:02:55 -08:00
Leonardo de Moura
2ca96cb2b0 feat: include macroStack in error messages 2020-01-01 15:19:04 -08:00
Leonardo de Moura
9d25a45074 feat: elaborate character literals 2020-01-01 14:37:40 -08:00
Leonardo de Moura
b1570ba865 feat: elaborate sortApp 2019-12-30 11:00:13 -08:00
Leonardo de Moura
74741bf613 feat: elaborate explicit universe levels 2019-12-30 10:52:22 -08:00
Leonardo de Moura
bceb02951c feat: better postpone messages 2019-12-22 10:24:22 -08:00