Hacker News new | past | comments | ask | show | jobs | submit login

Here's sum types in scala 3:

    for
      x <- fn1()
      y <- fn2(x)
      z <- fn3(y)
    yield z

That is both readable and safe, here fn1-fn3 all return an Either[Error,T] (the error type has to be common but the success type can vary by function).



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: