From a222d9d06acce8e1ddc2c13210bc11d7e6aa8090 Mon Sep 17 00:00:00 2001 From: meooow25 Date: Sun, 24 Nov 2024 22:23:18 +0530 Subject: [PATCH] Work around the warning for tail Ugh --- src/Regex/Internal/CharSet.hs | 7 +++++-- src/Regex/Internal/Debug.hs | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Regex/Internal/CharSet.hs b/src/Regex/Internal/CharSet.hs index 7258c06..d6adeae 100644 --- a/src/Regex/Internal/CharSet.hs +++ b/src/Regex/Internal/CharSet.hs @@ -230,7 +230,10 @@ unsafeChr (I# i#) = C# (chr# i#) -- | Is the internal structure of the set valid? valid :: CharSet -> Bool -valid cs = and (zipWith (<=) ls hs) - && all (>1) (zipWith (flip (-)) hs (tail ls)) +valid cs = noneEmpty && noneAdjacent where (ls,hs) = unzip (fmap (fmap ord) (IM.assocs (unCharSet cs))) + noneEmpty = and (zipWith (<=) ls hs) + noneAdjacent = case ls of + [] -> True + _:ls' -> all (>1) (zipWith (-) ls' hs) diff --git a/src/Regex/Internal/Debug.hs b/src/Regex/Internal/Debug.hs index 9dec967..724a3cd 100644 --- a/src/Regex/Internal/Debug.hs +++ b/src/Regex/Internal/Debug.hs @@ -177,7 +177,10 @@ labelToken node t = maybe (fromString . escape . disp) (filter (isJust . t) cs)) escape :: String -> String -escape = init . tail . show +escape = init . tail' . show + where + tail' (_:xs) = xs + tail' [] = error "tail'" (<+>) :: Str -> Str -> Str s1 <+> s2 = s1 <> " " <> s2