Skip to content

Commit

Permalink
solve #31 at least for the most part?
Browse files Browse the repository at this point in the history
  • Loading branch information
harisont committed Apr 24, 2023
1 parent dbfdf9c commit 60004e9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Errors.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ simplifyErrorPattern = bimap simplifyUDPattern simplifyUDPattern
where
(p1',p2') = if p1 == p2 then (TRUE,TRUE) else (p1,p2)
(p1s',p2s') = filterSubpatterns p1s p2s
-- simplification of sequence patterns only works if there is only one
-- error, like in DaLAJ sentences
(SEQUENCE p1s,SEQUENCE p2s) -> (SEQUENCE p1s',SEQUENCE p2s')
where (p1s',p2s') = unzip $ rmCommonPost $ rmCommonPre $ p1s `zip` p2s
(SEQUENCE_ p1s,SEQUENCE_ p2s) -> (SEQUENCE_ p1s',SEQUENCE_ p2s')
where (p1s',p2s') = unzip $ rmCommonPost $ rmCommonPre $ p1s `zip` p2s
ep -> ep
where
filterSubpatterns p1s p2s = if length p1s == length p2s
Expand Down
10 changes: 9 additions & 1 deletion src/Utils/Misc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ rmDuplicates (x:xs) | x `elem` xs = rmDuplicates xs

-- | Return all possible combinations of elements of a given list
combinations :: [a] -> [[a]]
combinations xs = sequence (replicate (length xs) xs)
combinations xs = sequence (replicate (length xs) xs)

-- | Remove the common prefix of a zipped list
rmCommonPre :: Eq a => [(a,a)] -> [(a,a)]
rmCommonPre = dropWhile (\(p1,p2) -> p1 == p2)

-- | Remove the common postfix of a zipped list
rmCommonPost :: Eq a => [(a,a)] -> [(a,a)]
rmCommonPost = reverse . rmCommonPre . reverse

0 comments on commit 60004e9

Please sign in to comment.