Skip to content
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
@maxtremblay

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).

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions