aboutsummaryrefslogtreecommitdiffstats
path: root/src/Test/VeriFuzz/Internal/Shared.hs
blob: 84e6af682b125c99f5430b66bca8d3196861758b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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