5 ms·
sigh no, what Python should actually have is a way to compose fallible computations such that if any one should fail, the entire composition short-circuits and
by mmirate 8y ago
sigh no, what Python should actually have is a way to compose fallible computations such that if any one should fail, the entire composition short-circuits and returns the error; while not needing each one to check its input for such a case.
It could even be generalized so that it would work properly even for things other than the ad hoc union-type formed by the billion-dollar mistake...
Why must so many languages incur upon themselves so much trouble by lacking such a simple thing as the monad abstraction?
- bvrmn 8y agoMonad abstraction is a mere crutch to fulfill compiler greed. It is not needed in dynamically typed langs.
- mmirate 8y ago> compiler greed What good compilers require, they repay hundredsfold in exhaustively eliminating entire categories of mistakes from every program that compiles without error.
- bvrmn 8y ago> they repay hundredsfold Most python apps is simple data proxies. Glue dicts from multiple sources into more complex dicts and pass further. If you will try to do proper modeling here you never accomplish a task.
- mmirate 8y agoOn the contrary. A simple data proxy involves not much computation, but mostly reshaping; what kind of thing you have becomes more important than what thing you have, and eliminating confusion in the former realm is precisely what static-typed code with proper modelling, excels at. And any competent static-typed language will have enough macro-like capabilities to generate the model code (along with as much of the boilerplate as possible) from a JSON Schema or similar. (Confusion in the latter realm, on the other hand, is one of the most common sources of remaining bugs once typing errors and other footguns are eliminated-with-prejudice.)
- bvrmn 8y agoIf you will do proper modeling in each intermidiate processing unit you never accomplish a task. It is software design 101. We check invariants on the endpoints not in the middle.
- pjz 8y ago...isn't that called a `try` block?
- mmirate 8y agoYes, except for things that helpfully return "None" instead of raising an exception, on account of "not finding something is not exceptional behavior" or something like that. And since "raise" is a statement, you have to write your own "raise_if_none" function and sprinkle it everywhere...