mirror of
https://github.com/github/semantic.git
synced 2025-01-02 20:41:38 +03:00
Define small-step interpretation in terms of decompose.
This commit is contained in:
parent
845ae84d9e
commit
cefd594191
@ -2,6 +2,7 @@
|
||||
module Interpreter (diffTerms) where
|
||||
|
||||
import Algorithm
|
||||
import Control.Applicative.Free
|
||||
import Data.Align.Generic
|
||||
import Data.Functor.Both
|
||||
import Data.Functor.Classes
|
||||
@ -12,7 +13,7 @@ import Data.These
|
||||
import Diff
|
||||
import Info
|
||||
import Patch (Patch, inserting, deleting, replacing, patchSum)
|
||||
import Prologue hiding (lookup)
|
||||
import Prologue hiding (lookup, Pure)
|
||||
import Syntax as S
|
||||
import Term
|
||||
|
||||
@ -108,6 +109,15 @@ runAlgorithm recur = iterAp $ \ r cont -> case r of
|
||||
Replace a b -> cont (replacing a b)
|
||||
where maybeRecur a b = if comparable a b then Just (recur (These a b)) else Nothing
|
||||
|
||||
|
||||
runStep :: (Eq leaf, HasField fields Category, HasField fields (Maybe FeatureVector))
|
||||
=> Algorithm (SyntaxTerm leaf fields) (SyntaxDiff leaf fields) result
|
||||
-> Either result (Algorithm (SyntaxTerm leaf fields) (SyntaxDiff leaf fields) result)
|
||||
runStep = \case
|
||||
Pure a -> Left a
|
||||
Ap algorithm cont -> Right $ cont <*> decompose algorithm
|
||||
|
||||
|
||||
-- | Decompose a step of an algorithm into the next steps to perform.
|
||||
decompose :: (Eq leaf, HasField fields Category, HasField fields (Maybe FeatureVector))
|
||||
=> AlgorithmF (SyntaxTerm leaf fields) (SyntaxDiff leaf fields) result -- ^ The step in an algorithm to decompose into its next steps.
|
||||
|
Loading…
Reference in New Issue
Block a user