Here's the approach I came across:
I already used a wrapper around Data.Acid.update (because it works in a monad with limited IO), and I realized that the wrapper can save the event in my own log. The limitation of UpdateEvent update implies SafeCopy update with runPut . safePut as runPut . safePut runPut . safePut I can serialize this to a ByteString . However ... this is a binary representation not intended for readability, and I would like to review it. I realized that reading an acid state event log from disk would have the same problem.
So, I added Show update to the limitations of my wrapper. In every place where the state is used, I added:
{-# LANGUAGE StandaloneDeriving #-} ... $(makeAcidic ''State ['update]) deriving instance Show Update
(StandaloneDeriving may be a bit inconsistent, but it does not cause problems with orphans here, as it is in the same file.)
In the wrapper, I now call show in the update and write the result to my own log file. Of course, this loses the atomicity of the update: perhaps the application crashes between the update call and my own logging, but I am ready to accept this risk.
xnyhps
source share