The class of foldable data structures that cannot be empty.
Methods
foldMap1 :: Semigroup m => (a -> m) -> f a -> mMap each element of the non-empty structure to a semigroup, and combine the results.
Example2 expressions foldMap1 SG.Sum (1 :| [2, 3, 4])Sum {getSum = 10}foldMap1 show (123 :| [456, 789, 0])"1234567890"
fold1 :: Semigroup m => f m -> mCombine the elements of a non-empty structure using a semigroup.
Example2 expressions fold1 (1 :| [2, 3, 4 :: SG.Sum Int])Sum {getSum = 10}fold1 (4 :| [5, 10 :: SG.Product Int])Product {getProduct = 200}
foldr1 :: (a -> b -> b) -> b -> f a -> bCombines the elements of a non-empty structure using a binary function
f.Example2 expressions foldr1 (+) 0 (1 :| [2, 3])6foldr1 (+) 1 $ Identity 34
toNonEmpty :: f a -> NonEmpty aConvert a non-empty data structure to a NonEmpty list.
Example1 expression toNonEmpty (Identity 2)2 :| []
head1 :: f a -> aThe first element of a non-empty data structure.
Example1 expression head1 (1 :| [2, 3, 4])1
last1 :: f a -> aThe last element of a non-empty data structure.
Example1 expression last1 (1 :| [2, 3, 4])4
maximum1 :: Ord a => f a -> aThe largest element of a non-empty data structure.
Example1 expression maximum1 (32 :| [64, 8, 128, 16])128
minimum1 :: Ord a => f a -> aThe smallest element of a non-empty data structure.
Example1 expression minimum1 (32 :| [64, 8, 128, 16])8
maximumOn1 :: Ord b => (a -> b) -> f a -> aThe largest element of a non-empty data structure with respect to the given comparison function.
Example1 expression maximumOn1 abs (0 :| [2, 1, -3, -2])-3
minimumOn1 :: Ord b => (a -> b) -> f a -> aThe smallest element of a non-empty data structure with respect to the given comparison function.
Example1 expression minimumOn1 abs (0 :| [2, 1, -3, -2])0
Instances7Foldable1, …
Foldable1 NonEmptyDefined in relude-1.2.0.0 · Relude.Extra.Foldable1Foldable1 IdentityDefined in relude-1.2.0.0 · Relude.Extra.Foldable1IsListError => Foldable1 []Defined in relude-1.2.0.0 · Relude.Extra.Foldable1⚠️CAUTION⚠️ This instance is for custom error display only.
Foldable1 is not supposed to be used with the lists.
In case it is used by mistake, the user will see the following:
Example1 expression head1 [1, 2, 3]...... The methods of the 'Foldable1' type class work with non-empty containers. However, one of the 'Foldable1' functions is applied to the List.... Possible fixes: * Replace [] with one of the: 'NonEmpty', 'Identity', '(c,)', 'Compose f g', 'Product f g', 'Sum f g' * Or use 'Foldable' class for your own risk....
Foldable1 (Tuple2 c)Defined in relude-1.2.0.0 · Relude.Extra.Foldable1(Foldable1 f, Foldable1 g) => Foldable1 (Product f g)Defined in relude-1.2.0.0 · Relude.Extra.Foldable1(Foldable1 f, Foldable1 g) => Foldable1 (Sum f g)Defined in relude-1.2.0.0 · Relude.Extra.Foldable1(Foldable1 f, Foldable1 g) => Foldable1 (Compose f g)Defined in relude-1.2.0.0 · Relude.Extra.Foldable1