Closed snowleopard closed 6 years ago
Good idea. Don't use put, use modify instead.
@ndmitchell Thanks! Will do the remaining changes later today.
@ndmitchell How does this look?
I preferred it without pushing MonadState into the trace functions. Before you could tell what the trace function did, what it read, when, where it went, what the outputs were etc. Now it just mutates arbitrary state however it pleases.
@ndmitchell I agree that it's not ideal. However, "it just mutates arbitrary state however it pleases" may be an exaggeration -- the difference is actually rather small:
verifyVT
-like functions could only read the whole VT
. Now they can both read and write the whole VT.recordVT
-like functions meant they could do an arbitrary change to the whole VT
, which is the same now.It's not clear that we really gained anything by this refactoring though: I'm pretty sure one can still make a subtle bug while mutating the state. So, I'm happy to abandon this PR (but I'll probably keep the removal of double-negation which was a bit confusing).
Removing the double negation seems fine - I was just trying to make everything compute dirty, for consistency, but that's no big deal.
I do prefer not having the monadstate. Could we make recordVT not take the initial trace and have the caller do modify <>?
Could we make recordVT not take the initial trace and have the caller do modify <>?
We can, but only in simplest cases. In general, recording a trace seems to require looking at the complete 'trace database', e.g. see DCT
.
Yep, to me that's interesting, and we shouldn't be seeking to unify all trace related functionality under the same interface - they all look at different fragments of the database, and that should be reflected in their API's.
@ndmitchell The bug you recently spotted in traces made me realise that we might want to move
record
andverify
functions fromMonad
toMonadState
context.Not sure if that's really an improvement, so raising this PR to discuss -- what do you think?