1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 00:42:33 +03:00

RWS employs strict state.

This commit is contained in:
Rob Rix 2017-06-15 09:10:58 -04:00
parent e15f5ad7ab
commit c12a2465a5

View File

@ -12,7 +12,8 @@ module RWS (
, defaultD
) where
import Prologue
import Prologue hiding (State, evalState, runState)
import Control.Monad.State.Strict
import Data.Record
import Data.These
import Patch
@ -134,10 +135,7 @@ findNearestNeighbourToDiff' :: (Diff f fields -> Int) -- ^ A function computes a
findNearestNeighbourToDiff' editDistance canCompare kdTrees termThing = case termThing of
None -> pure Nothing
Term term -> Just <$> findNearestNeighbourTo editDistance canCompare kdTrees term
Index i -> do
(_, unA, unB) <- get
put (i, unA, unB)
pure Nothing
Index i -> modify' (\ (_, unA, unB) -> (i, unA, unB)) >> pure Nothing
-- | Construct a diff for a term in B by matching it against the most similar eligible term in A (if any), marking both as ineligible for future matches.
findNearestNeighbourTo :: (Diff f fields -> Int) -- ^ A function computes a constant-time approximation to the edit distance between two terms.