diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2018-12-29 23:42:01 +0100 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2018-12-29 23:42:01 +0100 |
commit | 97462372591b8bae4eb34a35197c2b606c0c8bd7 (patch) | |
tree | 6918526729ed9a533d22cab564709724cd3e58d8 /src/Test/VeriFuzz/Internal/Shared.hs | |
parent | 8e4fab352bad77b91b248c1f50e1b0554793b689 (diff) | |
download | verismith-97462372591b8bae4eb34a35197c2b606c0c8bd7.tar.gz verismith-97462372591b8bae4eb34a35197c2b606c0c8bd7.zip |
Add internal function for fix
Diffstat (limited to 'src/Test/VeriFuzz/Internal/Shared.hs')
-rw-r--r-- | src/Test/VeriFuzz/Internal/Shared.hs | 6 |
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 |