Commit graph

1513 commits

Author SHA1 Message Date
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
cb9574b086 chore: test unboundImplicitLocals and cleanup 2020-11-22 10:33:28 -08:00
Leonardo de Moura
29303f17f3 chore: test unboundImplicitLocals 2020-11-22 09:48:15 -08:00
Leonardo de Moura
c7a31ed52e chore: remove duplicate instances 2020-11-21 11:05:52 -08:00
Leonardo de Moura
b672e37bcc chore: annotate OfNat and ToString default instances 2020-11-21 08:34:45 -08:00
Leonardo de Moura
e6215f7282 chore: remove some unnecessary commas 2020-11-20 15:47:27 -08:00
Leonardo de Moura
f3779f1542 feat: add support for unbound implicit locals 2020-11-20 12:22:27 -08:00
Leonardo de Moura
3323f7da60 feat: add instance Inhabited (Sort u) 2020-11-19 13:55:00 -08:00
Leonardo de Moura
90298ba476 feat: add helper instance 2020-11-19 11:32:54 -08:00
Leonardo de Moura
6551caf062 feat: define $ notation at Notation.lean 2020-11-19 09:10:19 -08:00
Leonardo de Moura
304c80d610 feat: use <| 2020-11-19 09:03:38 -08:00
Leonardo de Moura
f67c93191f feat: use |>. 2020-11-19 08:38:47 -08:00
Leonardo de Moura
87d97c24a7 chore: code convention 2020-11-19 08:13:11 -08:00
Leonardo de Moura
954d850e6d feat: add F# pipe notation 2020-11-19 08:12:53 -08:00
Leonardo de Moura
5cc110dd77 feat: add Array.appendCore for quotations
We need it before we can define the more efficient `Array.append`
2020-11-19 08:07:53 -08:00
Leonardo de Moura
c305c2691f chore: use := 2020-11-19 07:22:31 -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
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