... | @@ -303,3 +303,27 @@ allowed to be strict in case branches beyond it. |
... | @@ -303,3 +303,27 @@ allowed to be strict in case branches beyond it. |
|
|
|
|
|
See [Demand/IO-vs-ST](demand/io-vs-st) for some discussion of why we don't want to use the `IO` hack or allow `has_side_effects` to affect
|
|
See [Demand/IO-vs-ST](demand/io-vs-st) for some discussion of why we don't want to use the `IO` hack or allow `has_side_effects` to affect
|
|
demand analysis when we're working with strict `ST`.
|
|
demand analysis when we're working with strict `ST`.
|
|
|
|
|
|
|
|
## `IO` transactions?
|
|
|
|
|
|
|
|
|
|
|
|
Sometimes, we may not care about the distinctions above. Suppose we have an
|
|
|
|
action that performs several database operations in a transaction. If we hit
|
|
|
|
bottom performing any of the operations, then the whole sequence goes down
|
|
|
|
the drain (as long as we're careful to bracket appropriately to initiate and
|
|
|
|
terminate the transaction). In this case, it might be nice to allow the user
|
|
|
|
to state that these actions, despite being `IO`-like, are actually occurring
|
|
|
|
in an alternate universe. The trouble is that we could end up needing to compile
|
|
|
|
each action twice: once for when it is being performed as part of a transaction
|
|
|
|
and once for when it is being performed independently. I have no good story
|
|
|
|
for that as yet.
|
|
|
|
|
|
|
|
## Dreams
|
|
|
|
|
|
|
|
|
|
|
|
In my usual "let's break the entire world!" approach, I'd love to change the actual definition of `IO`
|
|
|
|
to something entirely different (one operational monad variant or another). I imagine the complaints
|
|
|
|
would be extremely loud. Aside from breaking the world, another potential downside of this approach is that it seems
|
|
|
|
likely harder to take advantage of knowledge that certain actions (e.g., `readIORef`) have no observable side effects.
|
|
|
|
On the plus side, we could remove absolutely all the I/O hacks from core-to-core that are necessary for
|
|
|
|
correctness, leaving only performance hacks. |