Hacker Newsnew | past | comments | ask | show | jobs | submit | mmstghjx's commentslogin

This is awesome! I love Haskell's syntax, but its adoption isn't where I'd like it to be.

One thing that I don't see is a way to mitigate the "andThen" pyramid of doom.

This happens when you have a language without early returns and you have chain multiple Result returning operations. You can use nested case expressions:

  case operation1 x of
      Ok value -> case operation2 value of
        Ok value2 -> value2
        Err msg -> "error from operation2: " ++ msg
      Err msg -> "error from operation1: " ++ msg

Or nested `andThen` calls

  operation1 x
     >> mapError (\msg -> "error from operation1: " ++ msg) 
     >> `andThen` (\value -> operation2 value)
     >> mapError (\msg -> "error from operation2: ++ msg)
This is nicer to read, but still a lot of noise.

Haskell has `do` notation to alleviate this but that brings with it the type-class that shall not be named.

Some languages, like Rust, introduce different per-type syntactical solutions such as `async/await` for Promises and `?` for Result.

I particularly like Gleam's `use` notation, which is syntactical sugar around functions that take a callback as their final argument.

Do you have a solution for this in Sky?


Real names didn't stop people from being arseholes on Facebook. They did lose a lot of friends, but they also found like minded friends, so kind of a wash.

Bingo. The Internet turns the other person into an abstraction.

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

Search: