aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-12-29 23:42:01 +0100
committerYann Herklotz <ymherklotz@gmail.com>2018-12-29 23:42:01 +0100
commit97462372591b8bae4eb34a35197c2b606c0c8bd7 (patch)
tree6918526729ed9a533d22cab564709724cd3e58d8
parent8e4fab352bad77b91b248c1f50e1b0554793b689 (diff)
downloadverismith-97462372591b8bae4eb34a35197c2b606c0c8bd7.tar.gz
verismith-97462372591b8bae4eb34a35197c2b606c0c8bd7.zip
Add internal function for fix
-rw-r--r--src/Test/VeriFuzz/Internal/Shared.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Test/VeriFuzz/Internal/Shared.hs b/src/Test/VeriFuzz/Internal/Shared.hs
index f2adda3..bf96509 100644
--- a/src/Test/VeriFuzz/Internal/Shared.hs
+++ b/src/Test/VeriFuzz/Internal/Shared.hs
@@ -25,6 +25,12 @@ sep :: (Monoid a) => a -> [a] -> a
sep el l = fromMaybe mempty $
(fromList . fmap (<>el) <$> safe init l) <> safe last l
+-- | Alternative sep which returns the pattern if the list is empty.
+sep_ :: (Monoid a) => a -> [a] -> a
+sep_ el l
+ | null l = mempty
+ | otherwise = el <> sep el l
+
-- | Converts unsafe list functions in the Prelude to a safe version.
safe :: ([a] -> b) -> [a] -> Maybe b
safe _ [] = Nothing