unison/unison-src/transcripts/fix614.md
2024-06-25 11:11:07 -07:00

55 lines
717 B
Markdown

```ucm:hide
scratch/main> builtins.merge
```
This transcript demonstrates that Unison forces actions in blocks to have a return type of `()`.
This works, as expected:
```unison
structural ability Stream a where emit : a -> ()
ex1 = do
Stream.emit 1
Stream.emit 2
42
```
```ucm:hide
scratch/main> add
```
This does not typecheck, we've accidentally underapplied `Stream.emit`:
```unison:error
ex2 = do
Stream.emit
42
```
We can explicitly ignore an unused result like so:
```unison
ex3 = do
_ = Stream.emit
()
```
Using a helper function like `void` also works fine:
```unison
void x = ()
ex4 =
void [1,2,3]
()
```
One more example:
```unison:error
ex4 =
[1,2,3] -- no good
()
```