From 7a2c4ed783c47f3d9c6392efc45a98a09fd9eaf3 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 4 Aug 2016 11:06:19 -0400 Subject: [PATCH] Generalize the Algorithm DSL over the term & diff types. --- src/Algorithm.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Algorithm.hs b/src/Algorithm.hs index 96d21ce9c..592377d6c 100644 --- a/src/Algorithm.hs +++ b/src/Algorithm.hs @@ -1,9 +1,7 @@ module Algorithm where import Control.Monad.Free.Church -import Diff import Prologue -import Term -- | A single step in a diffing algorithm. data AlgorithmF @@ -20,11 +18,11 @@ data AlgorithmF -- | A lazily-produced AST for diffing. type Algorithm term diff = F (AlgorithmF term diff) -recursively :: Term leaf annotation -> Term leaf annotation -> Algorithm (Term leaf annotation) (Diff leaf annotation) (Diff leaf annotation) +recursively :: term -> term -> Algorithm term diff diff recursively a b = wrap (Recursive a b pure) -byIndex :: [Term leaf annotation] -> [Term leaf annotation] -> Algorithm (Term leaf annotation) (Diff leaf annotation) [Diff leaf annotation] +byIndex :: [term] -> [term] -> Algorithm term diff [diff] byIndex a b = wrap (ByIndex a b pure) -bySimilarity :: [Term leaf annotation] -> [Term leaf annotation] -> Algorithm (Term leaf annotation) (Diff leaf annotation) [Diff leaf annotation] +bySimilarity :: [term] -> [term] -> Algorithm term diff [diff] bySimilarity a b = wrap (ByRandomWalkSimilarity a b pure)