Commit graph

1496 commits

Author SHA1 Message Date
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
bebca44773 feat: add println! macro for rewriting examples 2020-11-18 18:47:22 -08:00
Leonardo de Moura
7e533b4650 refactor: use Lists for Array reference implementation
Motivation: better reduction in the kernel.

cc @Kha
2020-11-17 17:05:53 -08:00
Leonardo de Moura
160a263049 chore: cleanup parsers 2020-11-17 14:29:32 -08:00
Leonardo de Moura
df0e4808ec feat: define tactic parsers using syntax command 2020-11-17 13:52:36 -08:00
Leonardo de Moura
4da5cdb13d chore: declare tactic parsers using syntax command 2020-11-17 13:35:21 -08:00
Leonardo de Moura
1d93eefada feat: add ! x notation for notFollowedBy(x) in the syntax command 2020-11-17 10:57:15 -08:00
Leonardo de Moura
77eaf17a47 refactor: move idDelta to Prelude.lean, add idRhs 2020-11-15 12:54:29 -08:00
Leonardo de Moura
db5fe843de chore: add expandInterpolatedStr helper function, rename msg! => m! 2020-11-14 13:52:52 -08:00
Leonardo de Moura
cc7d7422db fix: UInt ctors/fields in generated code 2020-11-14 12:50:32 -08:00
Leonardo de Moura
9acbc7bb7d feat: declare subtype notation using syntax 2020-11-14 08:46:02 -08:00
Leonardo de Moura
e1551afbd8 feat: add macro "exists" xs:explicitBinders ", " b:term : term
The ASCII version
2020-11-14 08:21:47 -08:00
Leonardo de Moura
99fad9fc4d feat: goodies for writing notation with binders 2020-11-14 07:32:44 -08:00
Leonardo de Moura
bed1582844 chore: remove workaround of the workaround 2020-11-14 07:04:17 -08:00
Leonardo de Moura
ffc4abed32 fix: UInt* and USize Inhabited instances 2020-11-13 16:30:48 -08:00
Leonardo de Moura
35f1844d16 feat: add ParserDescr.checkPrec 2020-11-13 16:00:31 -08:00
Leonardo de Moura
8c4ac7ccc1 refactor: rename LeanInit ==> Meta, and reduce dependencies 2020-11-13 16:00:31 -08:00
Leonardo de Moura
70385b87fa feat: add instance MonadRef MacroM 2020-11-13 16:00:31 -08:00
Leonardo de Moura
396e767f3d refactor: move Ref to Prelude and rename it to MonadRef
`MacroM` will implement `MonadRef` because
1- It will be easier to throw errors from macros
2- We will be able to `getRef` to retrieve the syntax node at macro
rules.

I renamed `Ref` to `MonadRef` to make it consistent with other classes
providing monadic methods (e.g. `MonadEnv`, `MonadState`, etc).

cc @Kha
2020-11-13 16:00:31 -08:00
Leonardo de Moura
f64d6c4514 feat: add ParserDescr.nodeWithAntiquot 2020-11-13 16:00:31 -08:00
Leonardo de Moura
65dafaf07c fix: stdlib and tests
We also declare a few macros for the syntax command.
2020-11-12 07:12:30 -08:00
Leonardo de Moura
3f95541a32 chore: delete temporary ParserDescrNew 2020-11-11 19:02:21 -08:00
Leonardo de Moura
3bfc5248ca chore: ParserDescrNew => ParserDescr 2020-11-11 18:57:49 -08:00
Leonardo de Moura
ba9a06dfc9 feat: compact ParserDescr 2020-11-11 18:52:26 -08:00
Leonardo de Moura
2eb76580f1 feat: add notation for coe 2020-11-11 16:39:01 -08:00
Leonardo de Moura
2537a2b84a chore: implement list and array literals using syntax command 2020-11-11 13:50:25 -08:00
Leonardo de Moura
78da6b3aa2 chore: add space for pretty printer 2020-11-11 11:39:11 -08:00
Leonardo de Moura
100670e3b5 feat: add if-then-else macros 2020-11-11 11:15:31 -08:00
Leonardo de Moura
b882dff754 chore: do not use if-then-else notation at Prelude.lean 2020-11-11 10:37:19 -08:00
Leonardo de Moura
5490235447 chore: remove renamed functions 2020-11-11 10:14:26 -08:00
Leonardo de Moura
f17e226638 chore: naming convention
Example: `mkNameStr` => `Name.mkStr`

cc @Kha
2020-11-11 10:08:55 -08:00
Leonardo de Moura
df5b7fdc24 chore: naming convention
Use namespaces (e.g., `mkStxLit` ==> `Syntax.mkLit`)

cc @Kha
2020-11-11 09:55:23 -08:00
Leonardo de Moura
dbf99a17b6 chore: define notation using infix commands 2020-11-11 08:26:12 -08:00
Leonardo de Moura
f936fe306c chore: fix annotation 2020-11-11 07:15:13 -08:00
Leonardo de Moura
bf7660ff5a chore: avoid infix operators at Prelude.lean
We also fix the copyright date
2020-11-11 06:56:45 -08:00
Leonardo de Moura
9c9d65e640 chore: move definitions needed by macros to Prelude.lean 2020-11-11 06:56:45 -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
c665d5e20a chore: cleanup 2020-11-10 15:40:00 -08:00
Leonardo de Moura
7f364feeb5 chore: add Classical.lean, Equivalence, and cleanup 2020-11-10 14:55:34 -08:00
Leonardo de Moura
7e51020685 chore: move SizeOf to its own file 2020-11-10 14:43:03 -08:00
Leonardo de Moura
bd5c668347 feat: add helper functions for new Prelude.lean 2020-11-10 12:34:40 -08:00
Leonardo de Moura
1c01bd59be chore: add numBitsEq 2020-11-10 11:59:16 -08:00
Leonardo de Moura
2daeb195b5 chore: use new names 2020-11-10 10:15:19 -08:00
Sebastian Ullrich
3d9f97574b refactor: use and improve mkAppStx 2020-11-10 10:11:24 -08:00
Leonardo de Moura
fdb7db5650 chore: rename Eq.subst argument 2020-11-08 14:05:17 -08:00
Leonardo de Moura
a8a457b355 refactor: move getTailInfo/copyTailInfo/etc to LeanInit 2020-11-08 11:52:14 -08:00
Leonardo de Moura
4a3b9c75e1 feat: add Quote Bool instance 2020-11-08 08:07:17 -08:00