aboutsummaryrefslogtreecommitdiff
path: root/src/Data/List/NonEmpty
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/List/NonEmpty')
-rw-r--r--src/Data/List/NonEmpty/Util.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Data/List/NonEmpty/Util.hs b/src/Data/List/NonEmpty/Util.hs
new file mode 100644
index 0000000..3a0e7f6
--- /dev/null
+++ b/src/Data/List/NonEmpty/Util.hs
@@ -0,0 +1,12 @@
+module Data.List.NonEmpty.Util where
+
+import Data.List.NonEmpty (NonEmpty(..))
+
+
+sconcatne :: Semigroup s => NonEmpty s -> s
+sconcatne = \(x :| xs) -> go x xs
+ where go a [] = a
+ go a (x : xs) = go (a <> x) xs
+
+foldMapne :: Semigroup s => (a -> s) -> NonEmpty a -> s
+foldMapne f = sconcatne . fmap f