This repository has been archived by the owner on Dec 22, 2023. It is now read-only.
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.
Error in the stream example of the abilities section #286
Open
Description
While reading the Abilities in Unison section, I tried to run the following example:
structural ability Stream e where
emit : e ->{Stream e} ()
-- equivalently
-- emit : e -> ()
Stream.range : Nat ->{} Nat ->{Stream Nat} ()
Stream.range n m =
if n >= m then ()
else
emit n
Stream.range (n + 1) m
However, I got the following error
The else clause of an if expression needs to
have the same type as the then clause.
Here, one is: Unit
and another is: Unit ->{Stream Nat} Unit
8 | if n >= m then ()
9 | else
10 | emit n
11 | Stream.range (n + 1) m
From the error message, I figured out I can replace the last line of the range definition by
Stream.range (n + 1) m ()
but this seems weird to me.
In case this is helpful, I am running release/M2j (built on 2021-10-07)
.