@@ -23,11 +23,13 @@ import Data.FunctorWithIndex (class FunctorWithIndex, mapWithIndex)
23
23
import Data.Maybe (Maybe (..), maybe )
24
24
import Data.Ord (class Ord1 )
25
25
import Data.Semigroup.Foldable (class Foldable1 , foldMap1 )
26
+ import Data.Semigroup.Foldable (foldl1 ) as Foldable1
26
27
import Data.Traversable (class Traversable , traverse , sequence )
27
28
import Data.TraversableWithIndex (class TraversableWithIndex , traverseWithIndex )
28
29
import Data.Tuple (uncurry )
29
30
import Data.Unfoldable (class Unfoldable , unfoldr )
30
31
import Data.Unfoldable1 (class Unfoldable1 )
32
+ import Prim.TypeError (class Warn , Text )
31
33
32
34
-- | A non-empty container of elements of type a.
33
35
-- |
@@ -47,8 +49,8 @@ singleton :: forall f a. Plus f => a -> NonEmpty f a
47
49
singleton a = a :| empty
48
50
49
51
-- | Fold a non-empty structure, collecting results using a binary operation.
50
- foldl1 :: forall f a . Foldable f => (a -> a -> a ) -> NonEmpty f a -> a
51
- foldl1 f (a :| fa) = foldl f a fa
52
+ foldl1 :: forall f a . Foldable f => Warn ( Text " 'Data.NonEmpty.foldl1' is deprecated, use 'Data.Semigroup.Foldable.foldl1' instead " ) => (a -> a -> a ) -> NonEmpty f a -> a
53
+ foldl1 = Foldable1 .foldl1
52
54
53
55
fromNonEmpty :: forall f a r . (a -> f a -> r ) -> NonEmpty f a -> r
54
56
fromNonEmpty f (a :| fa) = a `f` fa
@@ -108,7 +110,7 @@ instance foldable1NonEmpty :: Foldable f => Foldable1 (NonEmpty f) where
108
110
fold1 = foldMap1 identity
109
111
foldMap1 f (a :| fa) = foldl (\s a1 -> s <> f a1) (f a) fa
110
112
foldr1 f (a :| fa) = maybe a (f a) $ foldr (\a1 -> Just <<< maybe a1 (f a1)) Nothing fa
111
- foldl1 = foldl1
113
+ foldl1 f (a :| fa) = foldl f a fa
112
114
113
115
instance unfoldable1NonEmpty :: Unfoldable f => Unfoldable1 (NonEmpty f ) where
114
116
unfoldr1 f b = uncurry (:|) $ unfoldr (map f) <$> f b
0 commit comments