Thanks for the shout out Gershom!
I'd like to highlight that exceptions/effects as in the monad STE (aka ST + abort only semantics for exceptions) have a very very nice semantics: you can only handle the exceptions at the runMonad (runSTE :: (forall s. STE e s a) -> (Either e a -> b) -> b ) and you are *guaranteed* that the exceptions thrown are handled!
I've used it in certain interpreter style code dumps where i (private to the ST style computation) want to use mutation, but also want to be able to efficiently do a sort of "unsafeFreeze and export the entire heap" style "core dump" for debugging/reproducible efforts when the program execution/ interpreter would other wise "crash"
Monad-STE is essentially STE s e a === ExceptT e (ST s) a, but where the throwError isn't catchable, except ONLY by runSTE :: (forall s. STE e s a) -> (Either e a -> b) -> b
1) it definitely hits a nice choice in mixing exceptions and state, because by the time you're handling the exception, THERES NO STATE, so it becomes radically simpler to handle errors because theres *NO* state to cleanup :)
2) to my knowledge, its the only monad that naturally has a Monad Throw instance (in the IO ish flavored class) but no monad catch instance
3) likewise, to my knowledge its the only known PrimBaseMonad aside from IO and the ST family
4) it'd be cool to have it in BASE, but i'm not sure whats the right way to advocate it, though its certainly meaningfully distinct from IO and ST in possible uses, though in a complimentary way that perhaps supports a "haskell is a great imperative programming tool"
5) and at the very least it can be used for pure codes which also want to have efficient abortive errors AND efficient binds (any error monad that Uses either needs to case for Left's to do failure handling, this doesn't)
On Wed, Mar 21, 2018 at 12:41 AM, Gershom B <[hidden email]> wrote:
Libraries mailing list
|Free forum by Nabble||Edit this page|