3 ms·
I don't see how this is different than any other IO in most systems today. For instance, the moment you make an http request you can't possibly know for sure wh
by kilburn 7y ago
I don't see how this is different than any other IO in most systems today. For instance, the moment you make an http request you can't possibly know for sure what kind of response you'll get back.
However, you can strongly type your way from "string of bytes" all the way to "a Pet record" by parsing, and the calling side just receives a strongly typed result on the lines of "Result<Pet, Error>".
Why couldn't you do the same thing in BEAM?
- dnautics 7y agoIt's not that simple. What if the sending process is a human operator trying to introspect your system with a remote console, and a slightly misspelled token is sent? What is the right thing to do? Drop the message? Crash? Sometimes one thing is the right thing to do and sometimes the other. But messages are such a low level concept in erlang... It's really hard to make a strongly typed system that doesn't pick one over the other, which is going to be the wrong answer half the time. I'm not saying it can't be done, but many have tried and no one has succeeded yet.
- zachrose 7y agoI believe the right thing to do is to parse the response “into” an error and pass it to the error-handling branch that your compiler required when the handler was written. Or at least, that’s how it works in the statically typed language Elm, which guarantees that your compiled code will not throw any runtime errors.
- marci 7y agoFor those who want Elm + Erlang/Elixir, there's Elchemy http://elchemy.neontree.pl/new http://elchemy.neontree.pl/new