From 27c83d26737ee597e03cd3787319b76b804d52eb Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 7 May 2018 16:05:24 +0200 Subject: Better DFSTs --- edit-lens/src/Data/String/DFST.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/edit-lens/src/Data/String/DFST.hs b/edit-lens/src/Data/String/DFST.hs index 2eeb368..54a1336 100644 --- a/edit-lens/src/Data/String/DFST.hs +++ b/edit-lens/src/Data/String/DFST.hs @@ -19,7 +19,7 @@ import Control.Monad data DFST state = DFST { stInitial :: state - , stTransition :: Map (state, Char) (state, Maybe Char) + , stTransition :: Map (state, Char) (state, String) -- ^ All @(s, c)@-combinations not mapped are assumed to map to @(s, Nothing)@ , stAccept :: Set state } @@ -37,6 +37,6 @@ runDFST' :: forall state. Ord state runDFST' _ st [] acc = (st, acc) runDFST' dfst@DFST{..} st (c:cs) acc | Just (st', mc') <- stTransition !? (st, c) - = runDFST' dfst st' cs $ acc . maybe id (:) mc' + = runDFST' dfst st' cs $ acc . (mc' ++) | otherwise = runDFST' dfst st cs acc -- cgit v1.2.3