Unofficial Hacker News companion — get notified on comment replies, and more.

Roc version 0.1.0, eight years in the making (opens external site)

485 points by DrDeadCrash 3 days ago rtfeldman.com 134 comments (opens Hacker News) Vote (opens Hacker News)

View full thread · View on Hacker News

Comment thread (7)

  1. Roc seems to have a pretty good version of error handling I've seen so far: https://roc-lang.org/docs/main/langref/errors/

    Basically you can handle the errors you want to handle and propagate everything else upstream because the error value is a union of all propagated errors. In other (typed) languages you either need to handle all errors or map the different types into a single one.

    Replies (4)
    1. Have a look at the eros crate for rust. It implements a convenient error set mechanism mostly without macros
      Replies (1)
      1. That looks almost exactly like what I've wanted from rust errors - thanks! Sadly I hadn't seen that before.
    2. No recovery / restarts though.
    3.     y = U64.from_str(b) ? InvalidSecond   
          # returns Err(InvalidSecond(BadNumStr))
      
      Ooo, I like that syntax. Implicit wrapping, but it gives you a type you control so you can <do stuff> if needed.
    4. Isn't that how exceptions work, as the union of all possible defined exceptions?
      Replies (1)
      1. I differs that exceptions are hidden and you don't experience them until something happens so it's easier to forget to handle them (at least that is my experience). Here they are up front and visible and forces us to either handle or propagate them.