6 ms·
I think sometimes types lead to simpler designs. For example why can't "then" just have the following type: Promise A E -> (A -> A') -> (E -> E') -> Promise A'
by peq 12y ago
I think sometimes types lead to simpler designs. For example why can't "then" just have the following type:
Promise A E -> (A -> A') -> (E -> E') -> Promise A' E'
That would eliminate some strange corner cases and make it easier to explain the function. The special cases could just get their own functions.
Real algebraic data types would probably eliminate the need for E entirely and make it even simpler.
- acjohnson55 12y agoI would argue that `then` is better thought of as: Promise A E -> (A -> Promise A') -> (E -> Promise E') -> Promise A' E' , with implicit boxing of bare types and thrown exceptions, as well as flattening of superfluous Promise wrappers. The `flatMap`iness of it is what really makes it interesting, in my opinion.