Closed mikesol closed 3 years ago
Pretty sure merging this PR would break the guarantees of an indexed monad.
ipure x x a
means the "state" of the index does not change, which makes sense when you think about it. You're only lifting a value into a given indexed monad context. You're not using some API that changes the index's "state."
iwhen
and iunless
aren't as usable in indexed monads because indexed monads don't handle errors very well. Errors represent a fork in computations: one of two things could occur. What should be the state of the index at that point? Whenever the index's state is forked, one must 'unfork' it by handling the error immediately, which isn't always possible.
Yeah, Jordan has it right unfortunately! I understand the desire for this, but it basically would make ipure
something like unsafeCoerce
for the index, since you could just do something along the lines of void $ ipure unit
and that will freely change the index without actually performing an action that would affect the condition being tracked by the index types.
Makes total sense, thanks for the explanation!
I think (hope) this is legal - there seems to be precedent elsewhere for this: https://gist.github.com/gaku-sei/434d4de22dd66402728542cb9c3c7d35#file-indexedburger-re-L19. If this is swingable, it may solve a couple small issues in our codebase.