Exploring the Concept of a `TaggedError` for Library APIs
Would something like a
The idea is that in the context of a library you may have building blocks which are also part of the public API and you may want to give users a choice to use Effect, which means that if they choose not to, you need to unwrap the Effect and throw.
So instead of creating a tagged object and then creating the error, you could create a tagged error from the start.
and have an
Caveat is that you need to think of the error message where the failure happens, so you're not benefiting from decoupling the error management from the flow of the program so much, but since it's not a question of recovering from an error but only documenting it, maybe it's not that of a problem.
Any thougths?
TaggedError make any sense?The idea is that in the context of a library you may have building blocks which are also part of the public API and you may want to give users a choice to use Effect, which means that if they choose not to, you need to unwrap the Effect and throw.
So instead of creating a tagged object and then creating the error, you could create a tagged error from the start.
and have an
unwrapEffect function which creates a variant of a building block that throws your tagged error unconditionally:Caveat is that you need to think of the error message where the failure happens, so you're not benefiting from decoupling the error management from the flow of the program so much, but since it's not a question of recovering from an error but only documenting it, maybe it's not that of a problem.
Any thougths?
