Commit graph

48 commits

Author SHA1 Message Date
Leonardo de Moura
bfbfe94ac9 chore(library/init/control/default): add init.control.combinators 2019-02-07 09:12:53 -08:00
Sebastian Ullrich
d372139d27 feat(library/init/lean/elaborator): recursively elaborate lists of commands
This allows the expander to expand a single command to multiple commands
2018-12-07 10:29:58 +01:00
Sebastian Ullrich
7003fb6447 feat(library/init/lean/expander): command-level notations 2018-11-21 18:13:38 +01:00
Leonardo de Moura
38bc3beffb fix(library/init): alternative instances
Both `alternative` and `monad` implement `applicative`. However,
their default implementations for `seq_right` and `seq_left` are
different. The `alternative` implementation uses the inefficient default
version for `seq_right` available at `applicative`:
```
(seq_right := λ α β a b, const α id <$> a <*> b)
```
instead of the more efficient
```
(seq_right := λ α β x y, x >>= λ _, y)
```
defined at `monad` using the `bind` operator.

This commit makes sure the `applicative` instances for `reader_t`,
`state_t`, `option` and `parsec_t` use the efficient version.
I found the problem when inspecting the generated code for:
```
def symbol (s : string) : parsec' unit :=
(str s *> whitespace) <?> ("'" ++ s ++ "'")
```
2018-10-17 14:25:50 -07:00
Leonardo de Moura
effccf9a6d chore(library/init): mark a few combinators with [specialize] 2018-10-15 13:47:26 -07:00
Sebastian Ullrich
988d38b892 perf(library/init/control): inline monad_map instances even when partially applied 2018-10-04 14:23:03 -07:00
Sebastian Ullrich
0563c60b1a feat(library/init/lean/elaborator): add coroutine, use it to implement section/namespace elaborators (they don't do anything yet except for checking the end name) 2018-10-02 14:55:28 -07:00
Sebastian Ullrich
918388ac26 refactor(library/init/control/except): reintroduce except_t.mk 2018-10-02 14:55:28 -07:00
Sebastian Ullrich
e261d8f222 perf(library/init): missing [inline] attributes 2018-10-01 11:53:38 -07:00
Leonardo de Moura
7f64033111 chore(library/init): remove all occurrences of parameter command
We will not support the `parameter` command in Lean 4.
It is seldom used and creates many complications.
2018-09-26 17:54:11 -07:00
Leonardo de Moura
938c8dae83 fix(library/init/control/combinators): [inline] ==> [macro_inline] 2018-09-26 09:08:06 -07:00
Sebastian Ullrich
1d01e81de8 refactor(library/init/lean/parser): do not construct final syntax tree independent from intermediate outputs
This makes sure we have a single consistent view of the file
2018-09-25 18:28:53 -07:00
Sebastian Ullrich
d8b49e1dee feat(library/init/control/functor): add <&>, which the old elaborator likes better than <$> 2018-09-25 13:23:56 -07:00
Leonardo de Moura
a3a8165388 feat(library/init/control/monad): provide seq_right default implementation for monad
It was using the `seq_right` from `applicative` which is
```
(seq_right := λ α β a b, const α id <$> a <*> b)
```
and horrible code was being generated.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2018-09-20 08:39:25 -07:00
Leonardo de Moura
5ff9e24b17 feat(library/init/control): do not use unnecessary structures
It confuses the compiler.
2018-09-20 08:39:25 -07:00
Leonardo de Moura
11f98a409e chore(library/init/control/except): missing @[inline] annotations 2018-09-19 09:13:49 -07:00
Leonardo de Moura
d3e225ec65 fix(library/init): missing @[inline] 2018-09-18 21:42:22 -07:00
Leonardo de Moura
b07c718425 refactor(library/init/core): change ite signature 2018-09-17 14:27:28 -07:00
Leonardo de Moura
78317c5062 chore(library/init/control/combinators): remove dead notation 2018-09-12 17:34:25 -07:00
Leonardo de Moura
afd54039ab chore(library): remove >>, we should use *> 2018-09-12 17:31:21 -07:00
Leonardo de Moura
9e305a5f26 chore(library): remove return, we should use pure 2018-09-12 16:51:11 -07:00
Leonardo de Moura
da2de33245 fix(library/init/io): move coroutine_io implementation to io 2018-09-06 18:09:32 -07:00
Sebastian Ullrich
de9d894c14 feat(library/init/lean/parser/reader): use coroutine on the module level 2018-08-29 16:42:24 -07:00
Leonardo de Moura
7a47406c4c chore(library/tactic): remove simp_lemmas 2018-08-23 14:10:36 -07:00
Leonardo de Moura
c7cf75508d feat(init/control/coroutine): avoid mutual inductive
Reason: we want to delete the inductive compiler.
2018-08-23 10:49:40 -07:00
Sebastian Ullrich
3516c37ec9 feat(library/init/control/coroutine_io): coroutine_io 2018-08-21 08:43:10 -07:00
Sebastian Ullrich
6b55e24ab7 feat(library/init/{io,control/except}): use lift_t to automatically upcast io and other errors 2018-08-21 08:43:09 -07:00
Sebastian Ullrich
a260bf91d4 refactor(library/vm/vm_io,library/system/io): remove io classes, make errors explicit 2018-08-21 08:43:09 -07:00
Leonardo de Moura
8a96fde229 feat(library/init/control/coroutine): add coroutine
Remark: the termination proofs are commented because Lean 4 is
currently ignoring them and accepting non-terminating functions.

These files are based on an experiment implemented using Lean 3.
We can find it here:
https://gist.github.com/leodemoura/f5d82426c105b5fae0880e77024f6e9c

We will use coroutines to implement the interaction between reader,
elaborator and main driver.
2018-08-12 17:14:02 -07:00
Sebastian Ullrich
ea2bed7481 feat(library/init/control/combinators): make more universe polymorphic (for e.g. io) 2018-07-30 10:38:00 -07:00
Leonardo de Moura
c7762d07c1 feat(library/init/control/lift): add comment 2018-07-26 15:52:47 -07:00
Sebastian Ullrich
4e2234fd3a feat(library/init/control/state): remove monad_state.lift to avoid allocating tuples 2018-06-28 09:56:26 +02:00
Sebastian Ullrich
51d3ff21eb feat(library/init/control/state): monad_state: add specialized MonadState methods + modify
Absent inlining, these may perform better than `lift` when e.g. used with an
implementation based on unboxed tuples
2018-06-19 13:01:15 +02:00
Sebastian Ullrich
0f7c0ac8bf feat(init/lean/parser/parser): make a monad transformer
Also move parser combinators into the more specific namespace `init.lean.parser.parser_t`.
2018-06-04 12:57:23 +02:00
Leonardo de Moura
032a101262 chore(*): remove more files
@kha I'm trying to remove as much as possible before I start
modifying `expr`
2018-05-21 06:42:58 -07:00
Sebastian Ullrich
bba55aad47 feat(library/init/lean/trace): implement conditional tracing via good old trace classes 2018-05-18 14:52:15 +02:00
Leonardo de Moura
fbac1d45a3 refactor(library/init/control/combinators): move nat.mrepeat to combinators 2018-05-13 11:34:39 -07:00
Leonardo de Moura
8a6d2125b3 chore(library/init/control/combinators): remove top-level mmap and related combinators
The top-level `mmap` should use the `traversable` typeclass that will be
defined in the future.
2018-05-09 15:49:13 -07:00
Leonardo de Moura
014735e498 feat(library/init/control/combinators): remove unnecessary universe constraint from list.mmap'
This commit also adds the alias `mfor` for `mmap'`
2018-05-09 15:38:35 -07:00
Leonardo de Moura
83415ea44c feat(library/init/control/except): add instance has_monad_lift (except ε) (except_t ε m) 2018-05-09 12:19:44 -07:00
Leonardo de Moura
874f9caf13 feat(library/init/control/state): modify monad_run instance for state_t
@Kha, I was having to use `(run ...).1` in many places
in my code. So, I changed the instance
```
instance (σ m out) [monad_run out m] : monad_run (λ α, σ → out (α × σ)) (state_t σ m) :=
⟨λ α x, run ∘ (λ σ, x.run σ)⟩
```
to
```
instance (σ : Type u) (m out : Type u → Type v) [functor m] [monad_run out m] : monad_run (λ α, σ → out α) (state_t σ m) :=
⟨λ α x, run ∘ (λ σ, prod.fst <$> (x.run σ))⟩
```
If we want to get the resultant state in an action `act`, we can just
use `run (act >> get) init_state`.
2018-05-08 17:32:54 -07:00
Leonardo de Moura
4f75e49da8 feat(library/init/control/except): add monad_except _ except instance 2018-05-08 15:38:20 -07:00
Leonardo de Moura
e40f37b08e feat(library/init/lean/ir): add type checker 2018-05-07 18:07:04 -07:00
Leonardo de Moura
d5fe509c36 chore(*): remove end after each match-expression
`end` is not optional anymore
2018-05-04 11:30:06 -07:00
Leonardo de Moura
2cb6af9769 refactor(library/init/control): remove init.meta.name spurious dependency 2018-04-30 11:36:07 -07:00
Leonardo de Moura
9efd07d18c chore(library/init): move logic.lean => core.lean 2018-04-30 09:25:25 -07:00
Leonardo de Moura
13ba9ca176 feat(library/init/control/except): add has_repr and has_to_string instances 2018-04-27 13:39:19 -07:00
Leonardo de Moura
77d3a788e8 refactor(init): init/category ==> init.control 2018-04-27 08:33:08 -07:00