What a nut! Thank you to both. This is exactly what I needed.
This said, I think the reason I got myopic here was because I have the MonadCatch and MonadThrow as part of my app context. If only to build my skills here, how might I go about using functions that might call error?
If you can avoid getting there (i.e. error), better; as an example think of specific types which enforce some desiderable quality (NonEmpty, etc.). Or simply pattern matching:
case foo of
[] -> somethingElse
(a:as) -> a -- instead of `head a`
Lets note that catching pure exceptions can be brittle, an error can be at some intermediate step which is only evaluated late. This means one might need to catch it at every place where we evaluate the thunk. It’s better to either use total (non-partial) functions or be sure that the error case is not triggered because of some invariant that is satisfied.1
Great point. I’m really trying to swim against the current here for no benefit. I think that’s all there is for me to learn here… it makes me wonder why Data.Set has the findIndex in the first place. Thank you.