Copyright | (c) 2011-2015 Edward Kmett (c) 2018-2020 Kowainik |
---|---|
License | MIT |
Maintainer | Kowainik <xrom.xkov@gmail.com> |
Stability | Experimental |
Portability | Portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Documentation
class Foldable f => Foldable1 f where Source #
The class of foldable data structures that cannot be empty.
Since: 0.3.0
foldMap1 :: Semigroup m => (a -> m) -> f a -> m Source #
Map each element of the non-empty structure to a semigroup, and combine the results.
>>>
foldMap1 SG.Sum (1 :| [2, 3, 4])
Sum {getSum = 10}>>>
foldMap1 show (123 :| [456, 789, 0])
"1234567890"
fold1 :: Semigroup m => f m -> m Source #
Combine the elements of a non-empty structure using a semigroup.
>>>
fold1 (1 :| [2, 3, 4 :: SG.Sum Int])
Sum {getSum = 10}>>>
fold1 (4 :| [5, 10 :: SG.Product Int])
Product {getProduct = 200}
toNonEmpty :: f a -> NonEmpty a Source #
Convert a non-empty data structure to a NonEmpty list.
>>>
toNonEmpty (Identity 2)
2 :| []
The first element of a non-empty data structure.
>>>
head1 (1 :| [2, 3, 4])
1
The last element of a non-empty data structure.
>>>
last1 (1 :| [2, 3, 4])
4
maximum1 :: Ord a => f a -> a Source #
The largest element of a non-empty data structure.
>>>
maximum1 (32 :| [64, 8, 128, 16])
128
minimum1 :: Ord a => f a -> a Source #
The smallest element of a non-empty data structure.
>>>
minimum1 (32 :| [64, 8, 128, 16])
8
Instances
IsListError => Foldable1 [] Source # | ⚠️CAUTION⚠️ This instance is for custom error display only.
In case it is used by mistake, the user will see the following:
Since: 0.6.0.0 |
Foldable1 Identity Source # | Since: 0.3.0 |
Defined in Relude.Extra.Foldable1 | |
Foldable1 NonEmpty Source # | Since: 0.3.0 |
Defined in Relude.Extra.Foldable1 | |
Foldable1 ((,) c) Source # | Since: 0.3.0 |
Defined in Relude.Extra.Foldable1 | |
(Foldable1 f, Foldable1 g) => Foldable1 (Product f g) Source # | Since: 0.3.0 |
Defined in Relude.Extra.Foldable1 | |
(Foldable1 f, Foldable1 g) => Foldable1 (Sum f g) Source # | Since: 0.3.0 |
(Foldable1 f, Foldable1 g) => Foldable1 (Compose f g) Source # | Since: 0.3.0 |
Defined in Relude.Extra.Foldable1 |