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

717 B

scratch/main> 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
scratch/main> 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
  ()