module FeatureTraceRecording where
import Edits
import AST
import Feature
import FeatureTrace
type FeatureContext = FeatureFormula
type RecordedEdit g a = (Edit g a, FeatureContext)
type History g a = [RecordedEdit g a]
type Version g a = (FeatureTrace g a, AST g a)
type RecordingFunction g a = RecordedEdit g a -> Version g a -> FeatureTrace g a
type FeatureTraceRecording g a = EditType -> RecordingFunction g a
runFTR :: (Show a, Eq a) => FeatureTraceRecording g a -> Version g a -> History g a -> Version g a
runFTR :: FeatureTraceRecording g a
-> Version g a -> History g a -> Version g a
runFTR ftr :: FeatureTraceRecording g a
ftr startVersion :: Version g a
startVersion history :: History g a
history = [Version g a] -> Version g a
forall a. [a] -> a
last ([Version g a] -> Version g a) -> [Version g a] -> Version g a
forall a b. (a -> b) -> a -> b
$ FeatureTraceRecording g a
-> Version g a -> History g a -> [Version g a]
forall a g.
(Show a, Eq a) =>
FeatureTraceRecording g a
-> Version g a -> History g a -> [Version g a]
runFTRWithIntermediateSteps FeatureTraceRecording g a
ftr Version g a
startVersion History g a
history
runFTRWithIntermediateSteps :: (Show a, Eq a) => FeatureTraceRecording g a -> Version g a -> History g a -> [Version g a]
runFTRWithIntermediateSteps :: FeatureTraceRecording g a
-> Version g a -> History g a -> [Version g a]
runFTRWithIntermediateSteps ftr :: FeatureTraceRecording g a
ftr startVersion :: Version g a
startVersion = (Version g a -> (Edit g a, FeatureContext) -> Version g a)
-> Version g a -> History g a -> [Version g a]
forall b a. (b -> a -> b) -> b -> [a] -> [b]
scanl Version g a -> (Edit g a, FeatureContext) -> Version g a
record Version g a
startVersion
where record :: Version g a -> (Edit g a, FeatureContext) -> Version g a
record (f_old :: FeatureTrace g a
f_old, t_old :: AST g a
t_old) recordedEdit :: (Edit g a, FeatureContext)
recordedEdit@(edit :: Edit g a
edit, _)
= (FeatureTraceRecording g a
ftr (Edit g a -> EditType
forall g a. Edit g a -> EditType
edittype Edit g a
edit) (Edit g a, FeatureContext)
recordedEdit (FeatureTrace g a
f_old, AST g a
t_old), Edit g a -> AST g a -> AST g a
forall g a. Edit g a -> AST g a -> AST g a
run Edit g a
edit AST g a
t_old)