diff options
-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 |