Add way to clean up after exception #138
Replies: 1 comment
-
|
Fair topic! I don’t mind adding a few off the shelf functions from base. My usual approach is to find something unconstrained if it exists, i.e. without a type class constraint, and if it doesn’t exist, make a concrete version of a generic function qualified by type (e.g. Int.eq before I added Eq.eq). Otherwise one ends up pulling a thread leading to a lot of new stuff. Above all I want to maintain backwards compatibility which I consider a cornerstone of scripting languages. Exception.bracket, Exception.finally and Exception.onException all easily make it in and you could add today. Ones where you want to catch the exception need a bit of thought to add incrementally. E.g. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Designing glue languages is tricky, because if you add all the nice features, result won't be "glue" language anymore! But I'm wondering if there is possibility to add exception handling to Hell.
I could not find mentions of any exception handling function in docs (or maybe I'm just blind). But Haskell operations (especially related to disk-I/O) do throw exceptions (imagine reading file that was just deleted!), and as soon as an exception is thrown, Hell script will be terminated without any chance to clean temporary files, revert work half-done, etc.
Exceptions are extremely hard, but is it possible to add some rudimentary exception support? Maybe
onException/finally, they can be used to emulatetrapbehavior of bash, what seems to be enough for scripting.Another way to deal with errors is to return
Either Error afrom all function that may throw, like Rust does, but without some syntactic sugar resulting code might be very noisy.Beta Was this translation helpful? Give feedback.
All reactions