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)