TheBoringDev

u/TheBoringDev


I had an idea around how to solve the "function color" problem, and I'm looking for feedback on if what I'm thinking is possible.

The idea is that rather than having sync vs async functions, all functions are colorless but function return types can use monads with a "do" operator ? (similar to rust's operator for error handling, but for everything).

So you might have a function:

fn fetchUserCount(): Promise<Result<Option<int>>> {
  const httpResult: HttpResult = fetch("GET", "https://example.com/myapi/users/count")?; // do fetch IO
  const body: string = httpResult.body()?; // return error if couldn't get body
  const count: int = parseInt(body)?; // return None if canno
722

You've reached the end of this feed.