unison/unison-src/transcripts/fix614.md
2022-12-01 23:24:58 -06:00

695 B

.> builtins.merge

This transcript demonstrates that Unison forces actions in blocks to have a return type of ().

This works, as expected:

structural ability Stream a where emit : a -> ()

ex1 = do
  Stream.emit 1 
  Stream.emit 2
  42
.> add

This does not typecheck, we've accidentally underapplied Stream.emit:

ex2 = do
  Stream.emit
  42

We can explicitly ignore an unused result like so:

ex3 = do
  _ = Stream.emit
  ()

Using a helper function like void also works fine:

void x = ()

ex4 =
  void [1,2,3]
  ()

One more example:

ex4 =
  [1,2,3] -- no good
  ()