Arc Forumnew | comments | leaders | submitlogin
2 points by rocketnia 4301 days ago | link | parent

"I also just realized it might have some interesting uses as an alternative to exceptions. Rather than throwing an exception, you would instead return an object that has been tagged with an "exception" type."

This is monadic. Generally if you build a program out of a lot of functions of type (x -> MyWrap y) you can probably treat MyWrap as a monad, whereas if you build it out of a lot of functions of type (MyWrap x -> y) you can probably treat it as a comonad.

---

"By default this exception type would be propagated upwards until it reaches the top of the scope, but you can catch it by using pattern matching"

In this case you might be implementing it in a monadic way, but for most purposes the language user might as well treat it as a regular side effect.

I've been pondering the question of how to make the syntax of a language generic enough to integrate user-defined side effect models as though they're built in, just like this. However, this is a rabbit hole which has prevented me from getting very much done. :-p It's also straying pretty far from this thread's topic.