there are some hardcore functional programming concepts that I am trying to look at, but I am currently too biased with expectations to understand the edge cases
function divide(dividend: Real, divisor: Real) -> (Real | Error)
{
if(divisor == 0)
Error("Cannot divide by zero.")
dividend / divisor // would be some native code or shit
}
a classic example is the divide operation, which is not a (Real, Real) -> Real, because it also has a special output in case of a non-zero divisor
one way to "solve" it, which I am quite curious as to how that would turn out in the long term, is to have a subtype (or subset) of Real, NonZeroReal
but that violates one of my programming principles, in which you never abuse the type system for equal data structure with a subset of values (for example a uint or a non-empty-string)
at that point, it is no longer bound to functional programming
for any form of programming, violating your own principles is bad
for languages with exception handling, you can use try-catch-finally constructs to ensure that certain pieces of code always run
for languages with error-monads, you dont need the try-catch-finally construct, as you replaced it with the error-monad, and you can also ensure that certain pieces of code always run
except for some errors that the developers of the language didn't think of
which means that once you are aware of that risk, the developer is in perpetual fear of their code not running (probably not, but I would be)