Apply a strict left Fold to a lazy bytestring
Modulefoldl-1.4.18Haskell2010
Control.Foldl.ByteString
Folds for byte streams
- 4 types
- 1 class
- 18 values
- Packagefoldl-1.4.18
- Exports23
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceByteString.hs
Folding
2 declarationsApply a strict monadic left FoldM to a lazy bytestring
Folds
16 declarationsGet the first byte of a byte stream or return Nothing if the stream is empty
Get the last byte of a byte stream or return Nothing if the byte stream is empty
Return the length of the byte stream in bytes
Computes the maximum byte
Computes the minimum byte
(find predicate) returns the first byte that satisfies the predicate or
Nothing if no byte satisfies the predicate
(index n) returns the nth byte of the byte stream, or Nothing if the
stream has an insufficient number of bytes
(elemIndex w8) returns the index of the first byte that equals w8, or
Nothing if no byte matches
(findIndex predicate) returns the index of the first byte that satisfies
the predicate, or Nothing if no byte satisfies the predicate
count w8 returns the number of times w8 appears
Combine all the strict ByteString chunks to build a lazy ByteString
Re-exports
5 declarationsControl.Foldl re-exports the Fold type
Data.ByteString re-exports the ByteString type
Data.Word re-exports the Word8 type
Efficient representation of a left fold that preserves the fold's step function, initial accumulator, and extraction function
This allows the Applicative instance to assemble derived folds that traverse the container only once
A 'Fold a b' processes elements of type a and results in a value of type b.
Instances15Choice, Closed, Costrong, Profunctor, Semigroupoid, Cosieve, …
Choice FoldDefined in foldl-1.4.18 · Control.FoldlClosed FoldDefined in foldl-1.4.18 · Control.FoldlCostrong FoldDefined in foldl-1.4.18 · Control.FoldlProfunctor FoldDefined in foldl-1.4.18 · Control.FoldlSemigroupoid FoldDefined in foldl-1.4.18 · Control.FoldlCosieve Fold []Defined in foldl-1.4.18 · Control.FoldlFunctor (Fold a)Defined in foldl-1.4.18 · Control.FoldlApplicative (Fold a)Defined in foldl-1.4.18 · Control.FoldlComonad (Fold a)Defined in foldl-1.4.18 · Control.FoldlExtend (Fold a)Defined in foldl-1.4.18 · Control.FoldlFloating b => Floating (Fold a b)Defined in foldl-1.4.18 · Control.FoldlFractional b => Fractional (Fold a b)Defined in foldl-1.4.18 · Control.FoldlNum b => Num (Fold a b)Defined in foldl-1.4.18 · Control.FoldlSemigroup b => Semigroup (Fold a b)Defined in foldl-1.4.18 · Control.FoldlMonoid b => Monoid (Fold a b)Defined in foldl-1.4.18 · Control.Foldl
Instances9Profunctor, Functor, Applicative, Extend, Floating, Fractional, …
Functor m => Profunctor (FoldM m)Defined in foldl-1.4.18 · Control.FoldlFunctor m => Functor (FoldM m a)Defined in foldl-1.4.18 · Control.FoldlApplicative m => Applicative (FoldM m a)Defined in foldl-1.4.18 · Control.FoldlMonad m => Extend (FoldM m a)Defined in foldl-1.4.18 · Control.Foldl(Monad m, Floating b) => Floating (FoldM m a b)Defined in foldl-1.4.18 · Control.Foldl(Monad m, Fractional b) => Fractional (FoldM m a b)Defined in foldl-1.4.18 · Control.Foldl(Monad m, Num b) => Num (FoldM m a b)Defined in foldl-1.4.18 · Control.Foldl(Semigroup b, Monad m) => Semigroup (FoldM m a b)Defined in foldl-1.4.18 · Control.Foldl(Monoid b, Monad m) => Monoid (FoldM m a b)Defined in foldl-1.4.18 · Control.Foldl
The Foldable class represents data structures that can be reduced to a summary value one element at a time. Strict left-associative folds are a good fit for space-efficient reduction, while lazy right-associative folds are a good fit for corecursive iteration, or for folds that short-circuit after processing an initial subsequence of the structure's elements.
Instances can be derived automatically by enabling the DeriveFoldable
extension. For example, a derived instance for a binary tree might be:
{-# LANGUAGE DeriveFoldable #-}
data Tree a = Empty
| Leaf a
| Node (Tree a) a (Tree a)
deriving FoldableA more detailed description can be found in the Overview section of
Data.Foldable#overview.
For the class laws see the Laws section of Data.Foldable#laws.
Instances89Foldable, …
Foldable ComplexDefined in base-4.20.2.0 · Data.ComplexFoldable FirstDefined in base-4.20.2.0 · Data.SemigroupFoldable LastDefined in base-4.20.2.0 · Data.SemigroupFoldable MaxDefined in base-4.20.2.0 · Data.SemigroupFoldable MinDefined in base-4.20.2.0 · Data.SemigroupFoldable SCCDefined in containers-0.7 · Data.GraphFoldable IntMapDefined in containers-0.7 · Data.IntMap.InternalFolds in order of increasing key.
Foldable DigitDefined in containers-0.7 · Data.Sequence.InternalFoldable ElemDefined in containers-0.7 · Data.Sequence.InternalFoldable FingerTreeDefined in containers-0.7 · Data.Sequence.InternalFoldable NodeDefined in containers-0.7 · Data.Sequence.InternalFoldable SeqDefined in containers-0.7 · Data.Sequence.InternalFoldable ViewLDefined in containers-0.7 · Data.Sequence.InternalFoldable ViewRDefined in containers-0.7 · Data.Sequence.InternalFoldable SetDefined in containers-0.7 · Data.Set.InternalFolds in order of increasing key.
Foldable TreeDefined in containers-0.7 · Data.TreeFolds in preorder
Foldable MaybeSDefined in containers-0.7 · Utils.Containers.Internal.StrictMaybeFoldable NonEmptyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable IdentityDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.IdentityFoldable FirstDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable LastDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable DownDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable DualDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable ProductDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable SumDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListFoldable Par1Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable MaybeDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable SoloDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable HashedDefined in hashable-1.4.7.0 · Data.Hashable.ClassFoldable ArrayDefined in primitive-0.9.1.0 · Data.Primitive.ArrayFoldable SmallArrayDefined in primitive-0.9.1.0 · Data.Primitive.SmallArrayFoldable TyVarBndrDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxFoldable HashSetDefined in unordered-containers-0.2.21 · Data.HashSet.InternalFoldable VectorDefined in vector-0.13.2.0 · Data.VectorFoldable VectorDefined in vector-0.13.2.0 · Data.Vector.StrictFoldable []Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable U1Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable UAddrDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable UCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable UDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable UFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable UIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable UWordDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable V1Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable (Arg a)Defined in base-4.20.2.0 · Data.SemigroupFoldable (Map k)Defined in containers-0.7 · Data.Map.InternalFolds in order of increasing key.
Foldable (Array i)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable (Either a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable (Tuple2 a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.InternalFoldable f => Foldable (Lift f)Defined in transformers-0.6.1.1 · Control.Applicative.LiftFoldable f => Foldable (MaybeT f)Defined in transformers-0.6.1.1 · Control.Monad.Trans.MaybeFoldable m => Foldable (CatchT m)Defined in exceptions-0.10.9 · Control.Monad.Catch.PureBifoldable p => Foldable (Fix p)Defined in bifunctors-5.6.2 · Data.Bifunctor.FixBifoldable p => Foldable (Join p)Defined in bifunctors-5.6.2 · Data.Bifunctor.JoinFoldable (Const m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstFoldable (Baz t b)Defined in profunctors-5.6.3 · Data.Profunctor.TraversingFoldable (Tagged s)Defined in tagged-0.8.9 · Data.TaggedFoldable (Constant a)Defined in transformers-0.6.1.1 · Data.Functor.ConstantFoldable (bi a) => Foldable (Biap bi a)Defined in bifunctors-5.6.2 · Data.Bifunctor.BiapFoldable f => Foldable (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable f => Foldable (Alt f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable f => Foldable (Rec1 f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable f => Foldable (Backwards f)Defined in transformers-0.6.1.1 · Control.Applicative.BackwardsDerived instance.
Foldable f => Foldable (ExceptT e f)Defined in transformers-0.6.1.1 · Control.Monad.Trans.ExceptFoldable f => Foldable (IdentityT f)Defined in transformers-0.6.1.1 · Control.Monad.Trans.IdentityFoldable f => Foldable (WriterT w f)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.LazyFoldable f => Foldable (WriterT w f)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.StrictFoldable f => Foldable (Reverse f)Defined in transformers-0.6.1.1 · Data.Functor.ReverseFold from right to left.
Foldable w => Foldable (EnvT e w)Defined in comonad-5.0.9 · Control.Comonad.Trans.EnvFoldable (K1 i c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable (Forget r a)Defined in profunctors-5.6.3 · Data.Profunctor.Types(Foldable f, Foldable g) => Foldable (Product f g)Defined in base-4.20.2.0 · Data.Functor.Product(Foldable f, Foldable g) => Foldable (Sum f g)Defined in base-4.20.2.0 · Data.Functor.Sum(Foldable f, Foldable g) => Foldable (f :*: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Foldable(Foldable f, Foldable g) => Foldable (f :+: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableBifoldable p => Foldable (Flip p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.FlipBifoldable p => Foldable (WrappedBifunctor p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.WrappedFoldable (Clown f a)Defined in bifunctors-5.6.2 · Data.Bifunctor.ClownFoldable f => Foldable (M1 i c f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableFoldable g => Foldable (Joker g a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Joker(Foldable f, Foldable g) => Foldable (Compose f g)Defined in base-4.20.2.0 · Data.Functor.Compose(Foldable f, Foldable g) => Foldable (f :.: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Foldable(Foldable (f a), Foldable (g a)) => Foldable (Product f g a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Product(Foldable (f a), Foldable (g a)) => Foldable (Sum f g a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Sum(Foldable f, Bifoldable p) => Foldable (Tannen f p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Tannen(Bifoldable p, Foldable g) => Foldable (Biff p f g a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biff
A space-efficient representation of a Word8 vector, supporting many efficient operations.
A ByteString contains 8-bit bytes, or by using the operations from Data.ByteString.Char8 it can be interpreted as containing 8-bit characters.
Instances14IsList, Eq, Data, Ord, Read, Show, …
IsList ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.TypeEq ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.TypeData ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.TypeOrd ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.TypeRead ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.TypeShow ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.TypeIsString ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.TypeBeware: fromString truncates multi-byte characters to octets. e.g. "枯朶に烏のとまりけり秋の暮" becomes �6k�nh~�Q��n�
Semigroup ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.TypeMonoid ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.TypeNFData ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.TypeBinary ByteStringDefined in binary-0.8.9.3 · Data.Binary.ClassHashable ByteStringDefined in hashable-1.4.7.0 · Data.Hashable.ClassLift ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Typetype Item ByteString = Word8Defined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
8-bit unsigned integer type
Instances32Bounded, Enum, Eq, Integral, Data, Num, …
Bounded Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.WordEnum Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.WordEq Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.WordIntegral Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.WordData Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.DataNum Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.WordOrd Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.WordRead Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.ReadReal Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.WordShow Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.WordIx Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.WordBits Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.WordFiniteBits Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.WordStorable Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.StorablePrintfArg Word8Defined in base-4.20.2.0 · Text.PrintfNFData Word8Defined in deepseq-1.5.0.0 · Control.DeepSeqRandom Word8Defined in random-1.2.1.3 · System.RandomFinite Word8Defined in random-1.2.1.3 · System.Random.GFiniteUniform Word8Defined in random-1.2.1.3 · System.Random.InternalUniformRange Word8Defined in random-1.2.1.3 · System.Random.InternalBinary Word8Defined in binary-0.8.9.3 · Data.Binary.ClassHashable Word8Defined in hashable-1.4.7.0 · Data.Hashable.ClassPrim Word8Defined in primitive-0.9.1.0 · Data.Primitive.TypesUnbox Word8Defined in vector-0.13.2.0 · Data.Vector.Unboxed.BaseLift Word8Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxIArray UArray Word8Defined in array-0.5.8.0 · Data.Array.BaseVector Vector Word8Defined in vector-0.13.2.0 · Data.Vector.Unboxed.BaseMVector MVector Word8Defined in vector-0.13.2.0 · Data.Vector.Unboxed.BaseMArray IOUArray Word8 IODefined in array-0.5.8.0 · Data.Array.IO.InternalsMArray (STUArray s) Word8 (ST s)Defined in array-0.5.8.0 · Data.Array.Basedata MVector s Word8Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Basedata Vector Word8Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base