From 16c71b666f9fc8daf953d5749304b87b12637fe9 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Sun, 8 Jul 2018 21:57:08 +0000 Subject: [PATCH] Data.List.Local: Generalize input list to be any Foldable --- src/Data/List/Local.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Data/List/Local.hs b/src/Data/List/Local.hs index 06405e0..e7d5555 100644 --- a/src/Data/List/Local.hs +++ b/src/Data/List/Local.hs @@ -37,7 +37,7 @@ import Data.List.NonEmpty (NonEmpty (..), (<|)) -- -- >>> groupJusts [Nothing, Nothing, Just 1, Just 4, Nothing, Just 2] -- [[1, 4], [2]] -groupJusts :: [Maybe a] -> [NonEmpty a] +groupJusts :: Foldable f => f (Maybe a) -> [NonEmpty a] groupJusts maybes = prepend $ foldr go (Nothing, []) maybes where prepend (Nothing, l) = l @@ -47,7 +47,7 @@ groupJusts maybes = prepend $ foldr go (Nothing, []) maybes go (Just x) (Nothing, ls) = (Just $ x :| [], ls) go (Just x) (Just l , ls) = (Just $ x <| l , ls) -groupEithers :: [Either a b] -> ([b], [(NonEmpty a, NonEmpty b)], [a]) +groupEithers :: Foldable f => f (Either a b) -> ([b], [(NonEmpty a, NonEmpty b)], [a]) groupEithers = foldr go ([], [], []) where go (Left x) ([] , [] , as) = ([], [] , x : as)