transient-haskell / transient

A full stack, reactive architecture for general purpose programming. Algebraic and monadically composable primitives for concurrency, parallelism, event handling, transactions, multithreading, Web, and distributed computing with complete de-inversion of control (No callbacks, no blocking, pure state)
MIT License
630 stars 28 forks source link

Unify exceptions and finalization primitives #60

Closed harendra-kumar closed 5 years ago

harendra-kumar commented 7 years ago

The finish primitives are almost the same as the exception primitives. If we rename the finish primitive to throwException or equivalent we can just get rid or all other finish primitives and we get the ability to throw custom/user defined exceptions as well. With this, finish can just become a special exception type.

agocorona commented 7 years ago

Definitively yes. I missed some idiomatic way to tell the program: this process has finished, close all resources of this blocks since initFinish. but this also must be done in case of an exception. So they collide.

An special Finish exception may be called when the process finish normally and the resources are no longer needed. When whateverException hit, the best practice in complex cases is throw finish >> throw watheverException both. In simple cases, when no resources must be closed, finish is not needed.