From 91210dbc426e62e17d5cce50916c531e1367cc7e Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Thu, 23 Aug 2018 15:53:29 -0700 Subject: [PATCH] s/runOnce/stepMatcher --- src/Control/Abstract/Matching.hs | 18 +++++++++--------- src/Semantic/Util.hs | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Control/Abstract/Matching.hs b/src/Control/Abstract/Matching.hs index 7becc3fc7..eeb4b8b4e 100644 --- a/src/Control/Abstract/Matching.hs +++ b/src/Control/Abstract/Matching.hs @@ -12,7 +12,7 @@ module Control.Abstract.Matching , succeeds , fails , runMatcher - , runOnce + , stepMatcher ) where import Data.Algebra @@ -114,14 +114,14 @@ runMatcher :: (Alternative m, Monad m, Corecursive t, Recursive t, Foldable (Bas runMatcher m = para (paraMatcher m) paraMatcher :: (Alternative m, Monad m, Corecursive t, Foldable (Base t)) => Matcher t a -> RAlgebra (Base t) t (m a) -paraMatcher m t = runOnce (embedTerm t) m <|> foldMapA snd t +paraMatcher m t = stepMatcher (embedTerm t) m <|> foldMapA snd t -- | Run one step of a 'Matcher' computation. Look at 'runMatcher' if you want something -- that folds over subterms. -runOnce :: (Alternative m, Monad m) => t -> Matcher t a -> m a -runOnce t (Choice a b) = runOnce t a <|> runOnce t b -runOnce t Target = pure t -runOnce t (Match f m) = foldMapA (`runOnce` m) (f t) -runOnce _ (Pure a) = pure a -runOnce _ Empty = empty -runOnce t (Then m f) = runOnce t m >>= runOnce t . f +stepMatcher :: (Alternative m, Monad m) => t -> Matcher t a -> m a +stepMatcher t (Choice a b) = stepMatcher t a <|> stepMatcher t b +stepMatcher t Target = pure t +stepMatcher t (Match f m) = foldMapA (`stepMatcher` m) (f t) +stepMatcher _ (Pure a) = pure a +stepMatcher _ Empty = empty +stepMatcher t (Then m f) = stepMatcher t m >>= stepMatcher t . f diff --git a/src/Semantic/Util.hs b/src/Semantic/Util.hs index f19891df0..1cce27548 100644 --- a/src/Semantic/Util.hs +++ b/src/Semantic/Util.hs @@ -296,7 +296,7 @@ testChangeKV = do -- Temporary, until new KURE system lands. fromMatcher :: Matcher from to -> ProcessT (Eff effs) from (Either from (from, to)) -fromMatcher m = auto go where go x = maybe (Left x) (\y -> Right (x, y)) (runOnce x m) +fromMatcher m = auto go where go x = maybe (Left x) (\y -> Right (x, y)) (stepMatcher x m) -- Turn a 'ProccessT' into an FAlgebra. toAlgebra :: (Traversable (Base t), Corecursive t)