Commit graph

65 commits

Author SHA1 Message Date
Kim Morrison
7e8af0fc9d
feat: rename List.enum(From) to List.zipIdx, and Array/Vector.zipWithIndex to zipIdx (#6800)
This PR uniformizes the naming of `enum`/`enumFrom` (on `List`) and
`zipWithIndex` (on `Array` on `Vector`), replacing all with `zipIdx`. At
the same time, we generalize to add an optional `Nat` parameter for the
initial value of the index (which previously existed, only for `List`,
as the separate function `enumFrom`).
2025-01-28 23:34:30 +00:00
Cameron Zwarich
85560da3e4
chore: remove functions for compiling decls from Environment (#6600)
This PR removes functions from compiling decls from Environment, and
moves all users to functions on CoreM. This is required for supporting
the new code generator, since its implementation uses CoreM.
2025-01-13 18:51:06 +00:00
Leonardo de Moura
794228a982
refactor: Offset.lean and related files (#3614)
Motivation: avoid the unfold and check idiom.
This commit also minimize dependencies at `Offset.lean`.

closes #2615
2024-03-05 19:40:15 -08:00
Leonardo de Moura
e6d6855a85
chore: missing double backticks (#3587) 2024-03-04 03:02:35 +00:00
Henrik Böving
23e49eb519 perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
Sebastian Ullrich
4cd5b67271 chore: generalize parser kind detection 2022-11-14 12:53:18 +01:00
Sebastian Ullrich
ed03ff9d00 perf: cache leading_parser and syntax as well
We better hope the `leading_parser`s are closed terms
2022-11-11 09:13:02 +01:00
Mario Carneiro
dd5948d641 chore: snake-case attributes (part 1) 2022-10-19 09:28:08 -07:00
Mario Carneiro
6392c5b456 chore: import reductions 2022-09-15 14:02:38 -07:00
Mario Carneiro
6026894f9f doc: finish Init.Prelude docs 2022-08-09 14:25:44 -07:00
Leonardo de Moura
2ebcf29cde chore: use a[i]! for array accesses that may panic 2022-07-02 15:12:05 -07:00
Leonardo de Moura
69a446c8d1 feat: add field all to DefinitionVal and TheoremVal
Remark: we need an update stage0, and the field is not being updated
correctly set yet.
2022-06-23 16:13:26 -07:00
Leonardo de Moura
041827bed5 chore: unused variables 2022-06-07 17:54:10 -07:00
Leonardo de Moura
7d8f8c0fbe chore: style 2022-05-26 15:18:07 -07:00
Leonardo de Moura
12e2a79170 chore: fix codebase after removing auto pure 2022-02-03 18:08:14 -08:00
Leonardo de Moura
cf3b8d4eb4 chore: cleanup
Make the code style more uniform.
We still have a lot of leftovers from the old frontend.
2022-01-26 09:18:17 -08:00
Gabriel Ebner
9a2140b3db refactor: auto-generate (builtin)Parenthesizer attribute
We already generated `(builtin)Parenthesizer` (and `*Formatter`)
attributes for definitions tagged with `(builtin)*Parser`.  This commit
extends this support to all Parser-definitions, as long as we can
determine the syntax node kind syntactically (i.e., the parser
definition contains a leadingNode/node/trailingNode/nodeWithAntiquot
call).
2021-11-30 15:34:54 +01:00
Gabriel Ebner
bfc74decde feat: add info field to Syntax.node 2021-10-26 20:19:27 +02:00
Leonardo de Moura
3293e9ef08 chore: fix module comments, they must occur after the imports 2021-08-06 14:02:42 -07:00
Sebastian Ullrich
725c0c1911 chore: implement lhs prec 2021-03-22 16:33:37 +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
164577d94e chore: remove parser! and tparser!
The new macros are called "leading_parser` and `trailing_parser`.

cc @Kha
2021-03-11 09:36:58 -08:00
Sebastian Ullrich
0c91b3769e chore: replace variables in src/ 2021-01-22 14:36:05 +01: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
3d5082dde3 feat: simplify Attr.simple parser 2020-12-16 07:29:18 -08:00
Leonardo de Moura
ed87480093 refactor: move to attr syntax category 2020-12-15 20:22:04 -08:00
Sebastian Ullrich
4dfa7e1187 feat: use actual separator in sepBy antiquotation scope 2020-12-09 17:48:05 +01:00
Sebastian Ullrich
110b014752 chore: ParserCompiler: strip optParams 2020-12-09 17:36:26 +01:00
Leonardo de Moura
2408b5c6b5 feat: basic support for scoped attributes 2020-12-03 10:39:59 -08:00
Leonardo de Moura
0869f38de4 chore: update structure, class, inductive 2020-11-27 15:09:30 -08:00
Leonardo de Moura
f67c93191f feat: use |>. 2020-11-19 08:38:47 -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
bed1582844 chore: remove workaround of the workaround 2020-11-14 07:04:17 -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
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
fc4d991707 feat: add allowTrailingSep parameter to ParserDescr.sepBy and ParserDescr.sepBy1 2020-11-08 07:51:10 -08:00
Leonardo de Moura
34cba1ec2e feat: add withPosition and checkCol constructors 2020-11-08 06:42:25 -08:00
Leonardo de Moura
2d2d39c78e chore: use mut 2020-11-07 17:32:13 -08:00
Sebastian Ullrich
c1d75e21ea fix: fix pretty printers for imported ParserDescrs
... by interpreting them (imported or not) on the fly instead of storing them in the environment

/cc @leodemoura
2020-11-07 17:05:07 +01:00
Leonardo de Moura
6765440724 chore: remove clutter 2020-10-28 14:11:06 -07:00
Leonardo de Moura
c59f673f60 chore: cleanup 2020-10-28 09:33:19 -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
13c2a8ff51 chore: remove #lang lean4 header 2020-10-25 09:54:07 -07:00
Leonardo de Moura
b3678954f4 chore: move to new frontend 2020-10-20 17:19:05 -07:00
Leonardo de Moura
80a0200ab2 chore: move to new frontend
@Kha another significant milestone: all files at `src/Lean/Meta` are
being compiled with the new frontend.
2020-10-20 10:59:02 -07:00
Sebastian Ullrich
490c482af2 fix: allow [runParserAttributeHooks] on imported declarations, add non-builtin variant 2020-10-20 09:39:50 +02:00
Sebastian Ullrich
73065860f3 fix: refuse to generate code for imported parsers to avoid duplicate declarations 2020-10-20 09:38:44 +02:00