Commit graph

56 commits

Author SHA1 Message Date
Gabriel Ebner
a2f5959118 chore: use deriving Nonempty 2022-12-22 03:48:15 +01:00
Mario Carneiro
118d1027d2 feat: go to definition for KeyedDeclsAttributes 2022-11-16 11:16:24 +01:00
Mario Carneiro
dd5948d641 chore: snake-case attributes (part 1) 2022-10-19 09:28:08 -07:00
Mario Carneiro
391aef5cd7 feat: automatic extension names 2022-10-06 17:19:30 -07:00
Mario Carneiro
85119ba9d1 chore: move Std.* data structures to Lean.* 2022-09-26 05:46:04 -07:00
Mario Carneiro
6392c5b456 chore: import reductions 2022-09-15 14:02:38 -07:00
Mario Carneiro
603b7486e3 feat: add go-to-def for simple attributes 2022-07-31 16:36:54 +02:00
Leonardo de Moura
afce57386c chore: doc strings at KeyedDeclsAttribute.lean 2022-07-25 12:20:19 -07:00
Mario Carneiro
f6211b1a74
chore: convert doc/mod comments from /- to /--//-! (#1354) 2022-07-22 12:05:31 -07:00
Gabriel Ebner
a8cab84735 refactor: use computed fields for Expr 2022-07-11 14:19:41 -07:00
Leonardo de Moura
041827bed5 chore: unused variables 2022-06-07 17:54:10 -07:00
Sebastian Ullrich
897a5de6ac chore: revert some questionable signature changes 2022-06-07 16:37:45 -07:00
Sebastian Ullrich
ae7b895f7a refactor: unname some unused variables 2022-06-07 16:37:45 -07:00
Leonardo de Moura
12e2a79170 chore: fix codebase after removing auto pure 2022-02-03 18:08:14 -08:00
Leonardo de Moura
bac91b9b5b chore: remove arbitrary 2022-01-15 12:14:27 -08:00
Leonardo de Moura
e3241e82bc feat: define PointedType as { α : Type u // Nonempty α } 2022-01-14 20:36:51 -08:00
Sebastian Ullrich
e9f7c88299 feat: record doc strings of builtin parsers & elaborators 2021-11-26 17:13:19 +01:00
Sebastian Ullrich
8176084dcf refactor: factor out declareBuiltin 2021-11-26 17:13:19 +01:00
Leonardo de Moura
5a7badd69a feat: add support for erasing keyed attributes
This commit addresses any issue described at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Eq.2Endrec.20vs.20Eq.2Erec
2021-09-09 14:28:41 -07:00
Sebastian Ullrich
b82b90a687 feat: KeyedDeclAttribute: expose declaration names 2021-06-06 15:32:58 +02:00
Sebastian Ullrich
67519e226a chore: prepare change 2021-06-06 15:32:58 +02:00
Leonardo de Moura
ed1eee201a fix: avoid "failed to evaluate" error when extension has sorry
See updated test output.
2021-05-04 20:57:53 -07:00
Sebastian Ullrich
8f824ce141 fix: KeyedDeclsAttribute: preserve scopedness 2021-03-13 13:18:04 +01:00
Sebastian Ullrich
d88ef52b68 feat: scoped KeyedDeclsAttribute 2021-03-13 12:40:58 +01:00
Leonardo de Moura
be841a7cad chore: throwError! => throwError, throwErrorAt! => throwErrorAt
@Kha I marked the corresponding methods as `protected`.
I currently can't stand `throw_error`, and I am optimistic about
server highlighting feature you are working on :)
2021-03-11 11:59:45 -08:00
Leonardo de Moura
328c1bd9c2 chore: cleanup 2021-03-04 07:08:18 -08:00
Leonardo de Moura
ea0fda39bc chore: Declaration.lean naming convention
`Declaration.lean` was one of the first Lean 4 files, and was still
using an old naming convention.

cc @Kha
2021-01-20 17:07:02 -08:00
Leonardo de Moura
f0ac477d2e feat: add sanity checks 2021-01-01 18:31:28 -08:00
Leonardo de Moura
ed87480093 refactor: move to attr syntax category 2020-12-15 20:22:04 -08:00
Leonardo de Moura
3b6d65c3c3 chore: use deriving Inhabited 2020-12-13 10:09:20 -08:00
Leonardo de Moura
0ab368581a refactor: ScopedEnvExtension
1) `ScopedEnvExtension` module now mananges the push/pop/activate
methods. Motivations:
  - Easier to add attributes
  - One `ScopedEnvExtension` may be shared between multiple
  attributes (e.g., parsers)

2) Add `AttributeKind`
2020-12-04 16:22:43 -08:00
Sebastian Ullrich
39edb949c1 feat: allow KeyedDeclsAttribute without built-in attribute 2020-12-01 11:57:20 -08:00
Sebastian Ullrich
2a5c85d9e3 refactor: inline FormatMacro
@leodemoura: This was just a remnant of the initial frontend porting, correct?
2020-11-28 12:37:36 +01:00
Leonardo de Moura
0869f38de4 chore: update structure, class, inductive 2020-11-27 15:09:30 -08:00
Leonardo de Moura
d6f778bec4 refactor: arbitrary without explicit arguments
@Kha I was tired of writing `arbitrary _` :)
There 0 places in the stdlib where the type needs to be provided.
If in the future we need to specify the type we can use
`arbitrary (α := <type>)`
2020-11-25 09:07:38 -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
13c2a8ff51 chore: remove #lang lean4 header 2020-10-25 09:54:07 -07:00
Leonardo de Moura
0ab38742db chore: cleanup 2020-10-24 06:18:01 -07:00
Leonardo de Moura
82ee2e361b chore: cleanup 2020-10-21 18:43:47 -07:00
Leonardo de Moura
f8971200af chore: move to new frontend 2020-10-20 17:01:29 -07:00
Leonardo de Moura
84a0cd1f59 feat: add [builtinInit] attribute 2020-10-19 14:51:23 -07:00
Leonardo de Moura
e54a207986 refactor: provide Options to lean_eval_const
add `ImportM` monad for `addImportedFn`

cc @Kha
2020-10-19 10:21:38 -07:00
Leonardo de Moura
f4b5ec710f fix: fixes #175 2020-09-21 17:12:07 -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
b025c1c623 chore: remove HasEmptyc workarounds 2020-09-11 14:28:42 -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
0fc30f83f6 chore: remove dead file 2020-08-21 12:11:42 -07:00
Leonardo de Moura
c55376a1ba chore: more conventional MonadIO 2020-08-20 11:13:10 -07:00
Sebastian Ullrich
68b9a8e1d1 refactor: move parenthesizer compiler into separate file, generalize 2020-08-20 13:22:57 +02:00