Commit graph

369 commits

Author SHA1 Message Date
Sebastian Ullrich
bd7bb6f5b5 fix: do formatting 2020-11-25 11:30:24 +01:00
Leonardo de Moura
5585f9823f chore: cleaner structure/class syntax
@Kha I implemented the syntax for structure/class that we discussed this morning.
It is much cleaner. See new tests at `struct2.lean`.
I updated the documentation to use it.
2020-11-24 13:07:43 -08:00
Leonardo de Moura
5884b9c19a feat: add support for instance ... where
@Kha The fields are not mutually recursive yet, but it is good enough
 for writing examples in the manual.

See new test
2020-11-23 18:07:02 -08:00
Leonardo de Moura
ac85650e0a feat: add optional where clause at declarations
closes #191

@Kha Note that it expands into a "let rec".
There are many other places where an optional `where`-clause is
useful. We can add them later. It is relatively easy to add support in
other places using the new helper functions
`expandWhereDeclsOpt` and `expandMatchAltsWhereDecls`
2020-11-23 12:04:51 -08:00
Leonardo de Moura
3f27d7318e chore: prepare to add where clause to declarations 2020-11-23 10:41:12 -08:00
Leonardo de Moura
c7a31ed52e chore: remove duplicate instances 2020-11-21 11:05:52 -08:00
Leonardo de Moura
fcbd72f2af feat: optional , at structure instances 2020-11-20 15:24:34 -08:00
Leonardo de Moura
27e26998d2 chore: prepare to change structInst syntax 2020-11-20 13:57:52 -08:00
Leonardo de Moura
8a59fe5b52 feat: add ASCII version for · 2020-11-19 09:17:08 -08:00
Leonardo de Moura
d7d53bf3a8 chore: remove builtin $
We will define it at `Notation.lean`
2020-11-19 09:04:41 -08:00
Leonardo de Moura
b6a1914299 chore: remove $. notation
It has been replaced by `|>.`
2020-11-19 08:47:35 -08:00
Leonardo de Moura
91b3e3e318 feat: add pipe proj notation
We will delete `dollarProj`
2020-11-19 08:14:29 -08:00
Leonardo de Moura
c305c2691f chore: use := 2020-11-19 07:22:31 -08:00
Leonardo de Moura
0fcf6217ec feat: optional := before constructors in the inductive command
@Kha In the documentation, I will always use `:=`. The idea is to
avoid the issue: why does `structure` have a `:=` but `inductive`
doesn't.
2020-11-19 06:43:14 -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
a13c036181 chore: remove tactic builtin parsers 2020-11-17 13:34:05 -08:00
Leonardo de Moura
4a9c69c7f5 chore: add parser alias matchDiscr 2020-11-17 13:31:56 -08:00
Leonardo de Moura
e737de3384 chore: cleanup induction/cases notation 2020-11-17 11:48:55 -08:00
Leonardo de Moura
8751bbe2a8 fix: notation for non reserved symbols 2020-11-17 11:25:04 -08:00
Leonardo de Moura
3ad2d6c4e1 chore: add parser aliases 2020-11-17 11:15:17 -08:00
Leonardo de Moura
96db4985eb feat: allow anonymous antiquotations at ParserDescr.nodeWithAntiquot 2020-11-17 10:48:22 -08:00
Leonardo de Moura
dfa0b97916 chore: remove notSymbol hacks 2020-11-17 10:45:55 -08:00
Leonardo de Moura
da23b96b43 feat: improve error messages for syntax command 2020-11-17 10:33:53 -08:00
Leonardo de Moura
af8d616d5a feath: improve unary and binary parsers 2020-11-17 08:39:56 -08:00
Leonardo de Moura
360fa1638f chore: rename Parser.try to Parser.atomic
Reason: `try` is a keyword.

cc @Kha
2020-11-17 08:25:01 -08:00
Leonardo de Moura
0ddc2e5efb chore: remove builtin subtype notation 2020-11-14 08:42:03 -08:00
Leonardo de Moura
bed1582844 chore: remove workaround of the workaround 2020-11-14 07:04:17 -08:00
Leonardo de Moura
155c377bc6 chore: cleanup depArrow
Cleanup hack used before we implemented: parsers have precedence not tokens
2020-11-14 07:00:10 -08:00
Leonardo de Moura
35f1844d16 feat: add ParserDescr.checkPrec 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
d277b53c34 chore: remove dead code 2020-11-13 16:00:31 -08:00
Leonardo de Moura
61dfe2b1db fix: letDecl
use `simpleBinderWithoutType` at `declSig` and `optDeclSig`
2020-11-12 16:22:57 -08:00
Leonardo de Moura
cae6aa95dc feat: support simpleBinder at letDecl 2020-11-12 13:25:38 -08:00
Leonardo de Moura
22ff6bb125 chore: process indent' without underscore hack 2020-11-12 12:05:00 -08:00
Leonardo de Moura
9c331c92d8 chore: prepare to remove underscore hack 2020-11-12 11:50:02 -08:00
Leonardo de Moura
49d7a83934 chore: tacticSeq as a parser alias 2020-11-12 11:32:18 -08:00
Leonardo de Moura
bd76458210 feat: add support for nonReservedSymbol at syntax command 2020-11-12 07:32:18 -08:00
Leonardo de Moura
6fbaea6563 feat: simplify syntax command syntax 2020-11-12 07:01:20 -08:00
Leonardo de Moura
0510f746fc feat: add macro registerParserAlias!
It register the parser, parenthesizer, and formatter.
2020-11-11 19:34:14 -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
bd8bb163e2 feat: add parser aliases tables 2020-11-11 17:41:20 -08:00
Leonardo de Moura
792196e6a9 chore: remove list/array literal builtin parsers 2020-11-11 13:21:51 -08:00
Leonardo de Moura
fedd49de45 feat: remove if-then-else builtin parser 2020-11-11 10:57:06 -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
353aba579c chore: remove builtin infix operators 2020-11-11 07:23:28 -08:00
Sebastian Ullrich
e4f53fd92d chore: adjust list & array spacing 2020-11-10 10:11:24 -08:00
Leonardo de Moura
7e8a7e6660 feat: elaborate fun/forall binder extensions 2020-11-09 19:00:40 -08:00
Leonardo de Moura
25083fba9f feat: extend binder syntax 2020-11-09 18:41:48 -08:00