From 97462372591b8bae4eb34a35197c2b606c0c8bd7 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sat, 29 Dec 2018 23:42:01 +0100 Subject: Add internal function for fix --- src/Test/VeriFuzz/Internal/Shared.hs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') 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 -- cgit