Commit graph

29 commits

Author SHA1 Message Date
Gabriel Ebner
34b0b4b7e2 chore: fix tests 2022-08-15 08:55:25 -07:00
Leonardo de Moura
e9d85f49e6 chore: remove tryPureCoe?
Based on the discussion at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/for.2C.20unexpected.20need.20for.20type.20ascription/near/269083574
The consensus seemed to be that "auto pure" is more confusing than its worth.
2022-02-03 16:25:24 -08:00
Leonardo de Moura
04b7924154 chore: fix tests 2021-09-16 10:29:38 -07:00
Gabriel Ebner
3cff5ceb99 perf: make trace[...] ... notation lazy 2021-06-23 00:07:27 -07:00
Leonardo de Moura
d9273786c7 chore: remove when and «unless»
They are obsolete.

cc @Kha
2021-03-20 18:52:18 -07:00
Leonardo de Moura
48b855bfe5 chore: fix tests 2021-03-10 18:45:22 -08:00
Leonardo de Moura
9d304df757 feat: heterogeneous Append experiment
@Kha This one required a bunch of manual fixes. The main issue is that
before we added the string interpolation feature, we created
`MessageData`s using `++` and coercions. For example, given
`(e : Expr)`, we would write
```
let msg : MessageData := "type: " ++ e
```
and rely on the coercions `String -> MessageData` and
`Expr -> MessageData`, and the instance `Append MessageData`.
However, heterogeneous operators "block" the expected type propagation downwards.
This kind of code is obsolete now since we can write a more compact
version using string interpolation
```
let msg := m!"type: {e}"
```
2020-12-01 16:32:41 -08:00
Leonardo de Moura
db9e390b4d chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
Leonardo de Moura
474f9a3695 chore: fix tests 2020-10-22 17:46:15 -07:00
Leonardo de Moura
7c0b55ec6a chore: fix tests 2020-10-22 17:34:30 -07:00
Leonardo de Moura
9af0a0e18b feat: add withReader method
@Kha `withReader` is a well-behaved version of `adaptReader`. `adaptReader` is
too general, and it often produces counterintuitive elaboration
errors.

Here are two super annoying issues I hit all the time:
1- `adaptReader` + polymorphic code
```
def ex1 : ReaderT Nat IO Unit :=
adaptReader (fun x => x + 1) $
  IO.println "foo" -- 3 Errors here failed to synthesize `Monad ?m` and  `MonadIO ?m`, and don't know how to synthesize `Type → Type`
```

2- `adaptReader` and notation that requires the expected type
```
structure Context :=
(x y : Nat)

def ex2 : ReaderT Context IO Nat :=
adaptReader (fun s => { s with x := 10 }) $ -- Error at the structure instance
  ...
```
In the example above, I have to write `fun (s : Context) => ...` to
fix the problem.

The two problems above happen in the old and new frontends. However,
there is a new problem specific for the new frontend. In the new
frontend, a `do` is only elaborated when the expected type is known.
So, `adaptReader (fun ctx => ...) do ...` seldom works :(

As I said above, the issue is that `adaptReader` is too general. Its
type is
```
  {ρ ρ' : Type u_1} → {m m' : Type u_1 → Type u_2} → [MonadReaderAdapter ρ ρ' m m'] → {α : Type u_1} → (ρ' → ρ) → m α → m' α
```

`withReader` is a simpler version of `adaptReader`
```
withReader : {ρ : Type u_1} → {m : Type u_1 → Type u_2} → [MonadWithReader ρ m] → {α : Type u_1} → (ρ → ρ) → m α → m α
```
It doesn't have any of the problems above. Moreover, I managed to replace
every single instance of `adaptReader` with `withReader` at the stdlib
and tests. We don't need the `adaptReader` generality.
2020-10-13 15:00:17 -07:00
Leonardo de Moura
c10e92b348 chore: add temporary workarounds 2020-09-30 07:05:46 -07:00
Leonardo de Moura
ab44cd28f1 chore: move more tests to new frontend 2020-09-12 09:04:39 -07:00
Leonardo de Moura
99f3296828 refactor: simplify Util/Trace.lean 2020-08-28 17:36:44 -07:00
Leonardo de Moura
060f7f0f04 chore: fix tests 2020-08-23 19:58:41 -07:00
Leonardo de Moura
9c0bd9dd41 chore: fix tests 2020-05-26 15:05:00 -07:00
Leonardo de Moura
bd58048449 chore: { <source> with ... } syntax 2020-05-20 15:08:43 -07:00
Leonardo de Moura
1352619ee4 refactor: MonadTracer and helper functions
This commit adds
- `addContext : MessageData -> m MessageData` method. We need it to
  make sure we wrap the message with the current context. Before this
  commit I had to redefine `trace` for `MetaM`, `SynthM`, and
  `TermElabM`.
- polymorphic `traceM` method.
2019-12-08 09:05:15 -08:00
Leonardo de Moura
3422dbca5f chore: fix tests 2019-12-04 17:25:46 -08:00
Leonardo de Moura
41e574d6cc chore: fix tests 2019-11-05 14:44:05 -08:00
Leonardo de Moura
c330600197 chore: add example to demonstrate that messages are computed lazily 2019-10-22 17:12:42 -07:00
Leonardo de Moura
d51c291f2a refactor: simplify traceCtx 2019-10-22 16:36:18 -07:00
Leonardo de Moura
6498055656 chore: helper instances 2019-10-22 16:18:28 -07:00
Leonardo de Moura
f88561ae68 feat: add trace! macro 2019-10-22 16:08:37 -07:00
Leonardo de Moura
45e21168d2 feat: hierarchical trace kinds 2019-10-22 15:13:57 -07:00
Leonardo de Moura
0a0bc0b7b9 fix: remove unused parameter and add missing disableTracing 2019-10-22 15:04:44 -07:00
Leonardo de Moura
16099189f2 chore: minor adjustments 2019-10-22 14:57:26 -07:00
Leonardo de Moura
13faf9fdf6 feat: add trace prefix to options 2019-10-22 14:43:02 -07:00
Leonardo de Moura
3cd8dc6366 fix: minor issues and add MonadTracer test 2019-10-22 14:33:07 -07:00