Leonardo de Moura
b91e22af2b
fix: fixes #241
2021-05-22 19:10:07 -07:00
Leonardo de Moura
d46cb80362
chore: fix tests
2021-03-11 11:35:51 -08:00
Leonardo de Moura
06ad52575a
feat: force users to use discard when action result is not being bound and it is not PUnit
...
After this commit, we have to use an explicit `discard` in code such as
```
def g (x : Nat) : IO Nat := ...
def f (x : Nat) : IO Unit := do
discard <| g x -- type error without the `discard`
IO.println x
```
Motivation: prevent users from making mistakes such as
```
def f (xs : Array Nat) : IO Unit := do
xs.set! 0 1
IO.println xs
```
when they meant to write
```
def f (xs : Array Nat) : IO Unit := do
let xs := xs.set! 0 1
IO.println xs
```
2020-12-08 06:14:48 -08:00
Leonardo de Moura
b6a1914299
chore: remove $. notation
...
It has been replaced by `|>.`
2020-11-19 08:47:35 -08:00
Leonardo de Moura
c81dbeb53c
feat: improve smart unfolding
2020-11-15 17:34:37 -08:00
Leonardo de Moura
f1b88e1304
feat: add option for disabling smart unfolding and fix tests
2020-11-15 17:00:51 -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
d2e5c1c300
feat: improve dbgTrace! macro
2020-10-13 12:38:04 -07:00
Leonardo de Moura
9538772c1c
chore: do not use string interpolation by default at dbgTrace!
...
It is nice to be able to write `dbgTrace! x` instead of `dbgTrace! "{x}"`
2020-10-09 20:49:39 -07:00
Leonardo de Moura
bca81714fe
feat: println! and dbgTrace! macros with string interpolation
2020-10-09 17:19:04 -07:00
Leonardo de Moura
ef27af9cf8
test: string interpolation
2020-10-09 17:02:12 -07:00
Leonardo de Moura
d9d8e95987
feat: elaborate doElems at doLetArrow
...
@Kha The Rust `let+return` example works in Lean too :)
The Rust function
```rust
fn f (x : i32) -> i32 {
let y = if x == 0 { println!("x is zero"); return 100 } else { x + 1 };
println!("y: {}", y)
y
}
```
The Lean version is
```lean
def f (x : Nat) : IO Nat := do
let y ← if x == 0 then IO.println "x is zero"; return 100 else pure (x + 1)
IO.println ("y: " ++ toString y)
return y
```
The main missing feature now is the `try-catch-finally` `do` element.
2020-10-07 17:30:25 -07:00
Leonardo de Moura
ac07999e95
chore: cleanup do expander, and make sure it can handle the "easy" doLetArrows
2020-10-07 17:00:07 -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
ac1c0714a1
fix: expand macros in patterns before retrieving pattern variables
2020-10-07 09:15:05 -07:00
Leonardo de Moura
294a750110
feat: expand doMatch
2020-10-06 19:07:47 -07:00
Leonardo de Moura
f4ccb78014
feat: improve tryPureCoe? and document its limitations
2020-10-06 17:41:45 -07:00
Leonardo de Moura
3a426d96e7
feat: custom error message header at elabTermEnsuringType
...
This commit also improves `ensureTypeOf!` primitive.
2020-10-06 09:27:13 -07:00
Leonardo de Moura
5f28f2badc
test: add another do notation test
2020-10-05 19:19:18 -07:00
Leonardo de Moura
eac3ca9286
feat: let rec in do notation
2020-10-05 19:10:06 -07:00
Leonardo de Moura
43ce35985b
chore: fix test
2020-10-05 16:47:34 -07:00
Leonardo de Moura
eafd9bc0ad
feat: expand for x in xs notation
2020-10-05 15:37:34 -07:00
Leonardo de Moura
7a0cbdbe04
test: shadowing in do blocks
2020-10-05 11:51:17 -07:00
Leonardo de Moura
fb83e8e79b
feat: allow any variable to be reassigned
2020-10-05 11:25:19 -07:00
Leonardo de Moura
c10e92b348
chore: add temporary workarounds
2020-09-30 07:05:46 -07:00
Leonardo de Moura
765a8ac984
test: do with optional ;
2020-09-28 17:10:57 -07:00