Commit graph

15 commits

Author SHA1 Message Date
Kim Morrison
c3948cba24
feat: upstream definition of Vector from Batteries (#6197)
This PR upstreams the definition of `Vector` from Batteries, along with
the basic functions.
2024-11-24 23:01:32 +00:00
Leonardo de Moura
483f32edd8 feat: in pure code, do use assume Id monad at do notation
This feature produced counterintuitive behavior and confused users.
See discussion at #770.

As pointed out by @tydeu, it is not too much work to write `Id.run <|`
before the `do` when we want to use the `do` notation in pure code.

closes #770
2021-12-10 12:55:14 -08:00
Leonardo de Moura
6c6595cd9b feat: only allow variables declared with mut to be reassigned 2020-11-07 17:32:13 -08:00
Leonardo de Moura
81d6e065e7 chore: adjust files and tests 2020-11-07 17:32:12 -08:00
Leonardo de Moura
db9e390b4d chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
Leonardo de Moura
91aaab9e0d fix: error message location 2020-10-07 17:43:23 -07:00
Leonardo de Moura
5b76155318 feat: new return semantics
`return e` is not equivalent to `pure e` anymore.
Now, `return e` means "return value `e` as the result of the root `do` block".
2020-10-07 14:07:58 -07:00
Leonardo de Moura
e70dd03340 chore: remove forInMap 2020-10-07 10:01:04 -07:00
Leonardo de Moura
608ae62aef chore: use pure
We are planning to change the meaning of `return`
2020-10-06 15:53:53 -07:00
Leonardo de Moura
cda4de474b fix: weird error message in do notation
cc @Kha
2020-10-06 15:12:55 -07:00
Leonardo de Moura
db1b110f7e fix: use let* to avoid bad error messages in do notation
cc @Kha
2020-10-06 15:01:05 -07:00
Leonardo de Moura
82dad3c86f feat: add Code.returnAction 2020-10-06 13:19:55 -07:00
Leonardo de Moura
5110b1212d test: do notation error messages 2020-10-06 11:35:44 -07:00
Leonardo de Moura
13591e59d5 chore: improve regular 'for' error message 2020-10-06 11:30:14 -07:00
Leonardo de Moura
54e10776d4 feat: improve error messages for do notation
@Kha we are getting better error message, but we need to figure out a
way to suppress error messages that come from the "plumbing".
For example, in the following example.
```
def f4 (b : Bool) (n : Nat) (v : Vector Nat n) : Vector Nat (n+1) := do
if b then
  v := Vector.cons 1 v
Vector.cons 1 v
```
We get the nice "invalid reassignment" error at `v := ...`, but
we also get the nasty
```
error: application type mismatch
  jp✝ v
argument
  v
has type
  Vector Nat (n + 1)
but is expected to have type
  Vector Nat n
failed to synthesize instance
  CoeT (Vector Nat (n + 1)) v (Vector Nat n)
```
Where `jp✝` is a joinpoint created by the do-notation macro expander.
I thought about using `withoutErrToSorry` when elaborating the expanded
`do` term.
We may also try to add more helper hints such as `ensureTypeOf!` and
use them around "plumbing" code (e.g., "joinpoint goto"s)
2020-10-05 16:33:59 -07:00