Put interpreter's MorleyLogs into Writer
Clarification and motivation
Apparently, keeping MorleyLogs
in State
is not convenient, it would be more natural to keep it in Writer
monad.
(Note that the common concern about Writer
leaking memory does not apply here, because we work with lists and they take O(n)
memory in either way).
Why it is better to use Writer
:
- In debugger we want to be able to pick logs produced by every given instruction (that's part of requirements of DAP), and with
State
with have to evaluate the diff before/after instruction for that or reset logs after each instruction - both seems bad to me. - A similar case takes place in integrational testing framework - to implement
expectLog
we need to be able to pickMorleyLogs
from a single piece of scenario, and proper solution to this requires caryingMorleyLogs
inWriter
, not inStateT InternalState
. Though this problem is unreleated to our issue, I just mention it as an example.
Acceptance criteria
-
MorleyLogs
are not part ofInterpreterState
, rather accessible underEvalM
withMonadWriter MorleyLogs
. -
MorleyLogs
contain logs in direct order, not reversed one (and its usages are updated); an efficient representation for it is used. -
TODO
s in code are resolved.
Note
Let's wait until !685 (merged) is Merged to avoid conflicts
Edited by Stepan Prudnikov