Commit graph

1316 commits

Author SHA1 Message Date
Leonardo de Moura
18a7f5a489 feat: new name sanitizer 2020-09-16 11:57:55 -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
Sebastian Ullrich
a93a53b4b5 feat: more IO Task functions 2020-09-14 17:57:33 +02:00
Sebastian Ullrich
77cbaa752c fix: Task: make reference and -j0 semantics eager, simplify 2020-09-14 17:57:33 +02:00
Sebastian Ullrich
5b83ceb1b5 feat: IO.mapTask, IO.bindTask 2020-09-14 17:57:33 +02:00
Sebastian Ullrich
307a833798 feat: implement IO.asTask as primitive using always-run tasks 2020-09-14 17:57:33 +02:00
Sebastian Ullrich
c672bd657f feat: IO.asTask 2020-09-14 17:57:33 +02:00
Sebastian Ullrich
e14e76775f fix: ensure *println functions are atomic 2020-09-14 17:57:33 +02:00
Leonardo de Moura
ba4fdce508 feat: expand helper macros 2020-09-10 14:25:07 -07:00
Leonardo de Moura
34291e2151 feat: add Name.simpMacroScopes
@Kha We currently have a few macros that create binder names
such as `x`. These macros rely on the hygienic framework. This part is
great. Before this commit we were simply erasing the macro
scopes when creating the actual binders at `Expr.lean`.
The result produced expressions that were hard to debug.
For example, consider the following scenario

1- Macro creates a few binder names using ``x <- `(x)``
2- We create a lambda expression `t` with these binder names.
3- Then, we use `lambdaTelescope t fun xs body => ...`
   Now, if we trace `xs` and `body`, we get `#[x, x, ... x]` and
   we can't distinguish the different `x`s in `body`.
   So, it is really hard to debug anything using the traces.

This commit adds `Name.simpMacroScopes` for simplying "macro scoped"
names. Example: given `x._@.Init.Data.List.Basic._hyg.2.5`, it
produces `x.2.5`. I exported this function, and used it in the old
pretty printer.

I have considered modifying `lambdaTelescope` to make sure it creates
unused names. I think this option is bad because it introduces
overhead, and in a few places we want to preserve the binder names.

I have also considered replacing the `let x := x.eraseMacroScopes` at
`Expr.lean` with `let x := x.simpMacroScopes`. I think this option is
bad since we are destroying scoping information and will not be able
to distiguish which variables have macro scopes when processing
tactics.

Anyway, the solution in this commit is good for this week, but we
should discuss a more permanent solution next week.
2020-09-08 18:22:44 -07:00
Leonardo de Moura
ea2e86afba feat: add Array.allDiff 2020-09-08 16:16:14 -07:00
Leonardo de Moura
fc1e4cb533 feat: add Array.isPrefixOf 2020-09-08 14:40:43 -07:00
Leonardo de Moura
603f2dee73 fix: unnecessary get! 2020-09-08 13:15:57 -07:00
Leonardo de Moura
6704468f07 feat: add coeId instance
Add an example showing why it is useful.

TODO: reconsider whether we should use the approximation described in
the new test or not.
2020-09-06 08:27:26 -07:00
Leonardo de Moura
3ae3c51a8c feat: add Array.partition 2020-09-05 08:48:15 -07:00
Leonardo de Moura
0199e93079 chore: add Array.erase 2020-09-04 13:35:01 -07:00
Leonardo de Moura
3dbd2b728b feat: add Array.getMax? 2020-09-04 10:40:34 -07:00
Sebastian Ullrich
7083aeea83 chore: adapt to upstream 2020-08-31 06:50:01 -07:00
Wojciech Nawrocki
bbcc718c8d chore: more server fixes 2020-08-31 06:50:01 -07:00
Wojciech Nawrocki
7b9363c828 refactor: simplify document storage in server 2020-08-31 06:50:01 -07:00
Wojciech Nawrocki
4356017035 chore: copyright 2020-08-31 06:50:01 -07:00
Wojciech Nawrocki
86968b5c45 feat: fix UTF-8/16 and add ServerM monad
Emojis work now 🎉
2020-08-31 06:50:01 -07:00
Marc Huisinga
e7b3d0be59 feat: initial server implementation 2020-08-31 06:50:01 -07:00
Sebastian Ullrich
1fb1a6f913 fix: do not expose invalid process handles when not redirected 2020-08-30 14:28:56 -07:00
Sebastian Ullrich
9f40e46043 feat: basic process API 2020-08-30 14:28:56 -07:00
Leonardo de Moura
27170cddb9 feat: mark Lean.ofReduceBool and Lean.ofReduceNat as axioms
The idea is to inform users whether their trust code base depends on
the compiler, interpreter, `[implementedBy]` and `[extern]`
annotations.
2020-08-28 12:22:12 -07:00
Sebastian Ullrich
95901a0346 fix: make Stream.ofBuffer thread-safe 2020-08-28 10:04:32 -07:00
Sebastian Ullrich
110ae4b571 feat: replace OS-specific stream redirection with pure-Lean Stream redirection
This avoids the temporary files workaround on macOS and Windows, and makes sure
we can process a `#eval` command and write messages to stdout at the same time.
2020-08-28 10:04:32 -07:00
Sebastian Ullrich
efa119bc94 feat: make std streams Streams 2020-08-28 10:04:32 -07:00
Sebastian Ullrich
56fda835be feat: add ByteArray <-> String conversions 2020-08-28 10:04:32 -07:00
Sebastian Ullrich
dbebff3a2d feat: ByteArray.copySlice 2020-08-28 10:04:32 -07:00
Sebastian Ullrich
1b0ffbb74d feat: make std IO streams settable
Co-authored-by: Simon Hudon <simon.hudon@gmail.com>
2020-08-28 10:04:32 -07:00
Leonardo de Moura
47ff4d0e8e chore: add helper functions
TODO: we should `Subarray` and functions/methods for it. Then, we can delete
functions such as `foldlFromM`
2020-08-27 14:58:27 -07:00
Leonardo de Moura
f8db5d2652 fix: must use lean_mk_task_own 2020-08-27 12:21:10 -07:00
Leonardo de Moura
5efa628e43 chore: split Lift.lean into MonadLift.lean, MonadFunctor.lean, and MonadRun.lean 2020-08-26 08:34:35 -07:00
Leonardo de Moura
321719b300 feat: add MonadFinally 2020-08-25 17:58:35 -07:00
Leonardo de Moura
31716731ba chore: cleanup 2020-08-25 15:06:12 -07:00
Leonardo de Moura
1103806ff4 refactor: HasMonadLift ==> MonadLift 2020-08-25 13:54:41 -07:00
Leonardo de Moura
b03cd748cf feat: add MonadControl 2020-08-25 13:54:41 -07:00
Sebastian Ullrich
8630d78b3f fix: Int.add spec 2020-08-24 13:55:14 +02:00
Leonardo de Moura
b672f0820b chore: remove workarounds 2020-08-23 19:56:01 -07:00
Leonardo de Moura
6fc935f6d1 refactor: add MonadNameGenerator 2020-08-23 19:56:01 -07:00
Leonardo de Moura
d85836a387 chore: mark TODO 2020-08-23 19:55:53 -07:00
Leonardo de Moura
6180ba6d7d chore: rename ST.Ref primitives 2020-08-23 12:28:14 -07:00
Leonardo de Moura
77b9445544 feat: real ST monad
@Kha: the new `ST` (and `EST`) are escapable like the Haskell ST monad.
It makes `StateRefT` much more useful because we can now run it from pure
code.
2020-08-23 12:15:32 -07:00
Leonardo de Moura
37571edce5 fix: remove unnecessary dependencies 2020-08-22 15:15:10 -07:00
Leonardo de Moura
916b395d1b chore: cleanup 2020-08-21 09:29:09 -07:00
Leonardo de Moura
05a0e7f6d0 refactor: build all main monads on top of ECoreM 2020-08-20 18:36:04 -07:00
Leonardo de Moura
fad6235abb feat: give a name to EIO Empty
@Kha I am calling it `ST` for lack of a better name. It makes some
sense since only the `IO.Ref` operations are in `EIO Empty` :)
That being said, it may confuse Haskell users.

BTW, I had to give the name to avoid a nontermination in the TC
procedure when using
```lean
instance EIOEmpty.monadLift {ε} : HasMonadLift (EIO Empty) (EIO ε) :=
{ monadLift := fun α => fromEmptyEIO }
```
2020-08-20 15:47:27 -07:00
Leonardo de Moura
eebc611391 chore: remove unnecessary workaround 2020-08-20 13:15:11 -07:00