diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2018-12-01 16:48:13 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2018-12-01 16:48:13 +0000 |
commit | dbe0a9e8250477728eb8a652fc92c35dbd018830 (patch) | |
tree | d439b5eee60eaa4708636f34e7839deac9f2c289 /src/Test/VeriFuzz/Internal | |
parent | 88d11885a84d09f201db639a98ecf513b519fa0a (diff) | |
download | verismith-dbe0a9e8250477728eb8a652fc92c35dbd018830.tar.gz verismith-dbe0a9e8250477728eb8a652fc92c35dbd018830.zip |
Add more code to the shared code
Diffstat (limited to 'src/Test/VeriFuzz/Internal')
-rw-r--r-- | src/Test/VeriFuzz/Internal/Shared.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Test/VeriFuzz/Internal/Shared.hs b/src/Test/VeriFuzz/Internal/Shared.hs index 584ecfd..84e6af6 100644 --- a/src/Test/VeriFuzz/Internal/Shared.hs +++ b/src/Test/VeriFuzz/Internal/Shared.hs @@ -1,4 +1,14 @@ module Test.VeriFuzz.Internal.Shared where +import Data.Maybe (fromMaybe) + fromList :: (Foldable t, Monoid a) => t a -> a fromList = foldl mappend mempty + +sep :: (Monoid a) => a -> [a] -> a +sep el l = fromMaybe mempty $ + (fromList . fmap (<>el) <$> safe init l) <> safe last l + +safe :: ([a] -> b) -> [a] -> Maybe b +safe _ [] = Nothing +safe f l = Just $ f l |