unison icon indicating copy to clipboard operation
unison copied to clipboard

lambda sometimes is missing a let when pretty-printing

Open aryairani opened this issue 3 years ago • 2 comments

failing transcript:

Setup:

```ucm:hide
.> builtins.merge
```
```unison:hide:all
map f a =
    go i as acc =
      match List.at i as with
        None   -> acc
        Some a ->
          use Nat +
          go (i + 1) as (acc :+ f a)
    go 0 a []
```
```ucm:hide
.tmp> add
```

Issue: This doesn't parse without let, but the pretty printer removes the let. I don't know whether it should need the let, but it does.


```unison:hide
x = map
      (i -> let
        x = i + 1
        y = x + 1
        z = y + 1
        z) [1, 2, 3]
```
```ucm
.tmp> add
.tmp> edit x
.tmp> load
```

aryairani avatar Feb 09 '22 22:02 aryairani

Hopefully will fix these definitions from [website]:

  • [ ] fundamentals.valuesAndFunctions.functionsOnCollections

aryairani avatar Feb 10 '22 06:02 aryairani

This, like #4733 seems to have been fixed in the round-trip, but leaves some incorrect definitions in codebases. If I use the from-scratch examples in this issue or #3757, things work correctly. But if I use metadata.licenseTypes.bsd2.doc (fundamentals.valuesAndFunctions.functionsOnCollections doesn’t seem to exist any more), we’re still missing the let.

So, this was clearly a parsing-side error, and the pretty-printer is just doing what it’s been told. But I now have the same question as the one I asked on #4733.

sellout avatar Aug 20 '24 22:08 sellout