proto3-wire-1.4.6: A low-level implementation of the Protocol Buffers (version 3) wire format
Safe HaskellNone
LanguageHaskell2010

Proto3.Wire.Encode.Repeated

Description

Presents right-associative folds as Foldable sequences.

Synopsis

Documentation

data Repeated (e :: TYPE er) Source #

Expresses a sequence of values in reverse order for encoding as a repeated field.

Constructors

ReverseRepeated 

Fields

  • countRepeated :: Maybe Int

    Optionally predicts the number of elements in the sequence. Predict the count only when it is practical to do so accurately and quickly.

    A prediction that is too low causes undefined behavior--possibly a crash. A length prediction that is too high overallocates output space, as if the sequence really were that length.

  • reverseRepeated :: FoldR e

    A lazy right-associative fold over the reverse of the desired sequence of field values.

    Design Note: We could have used a lazy left-associative fold, but vectors perform such folds using a left-to-right iteration, instead of the right-to-left iteration that would yield best performance.

    Therefore in order to avoid accidental misuse of foldl, we ask for sequence reversal explicitly. Thanks to vector fusion rules, it is fast to foldr on the result of reversing a vector.

Instances

Instances details
ToRepeated (Repeated e :: Type) (e :: TYPE er) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

Functor (Repeated :: Type -> Type) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

Methods

fmap :: (a -> b) -> Repeated a -> Repeated b #

(<$) :: a -> Repeated b -> Repeated a #

Generic (Repeated e) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

Associated Types

type Rep (Repeated e) 
Instance details

Defined in Proto3.Wire.Encode.Repeated

type Rep (Repeated e) = D1 ('MetaData "Repeated" "Proto3.Wire.Encode.Repeated" "proto3-wire-1.4.6-CRlwbrcQnvz56vF5AH6Bds" 'False) (C1 ('MetaCons "ReverseRepeated" 'PrefixI 'True) (S1 ('MetaSel ('Just "countRepeated") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Int)) :*: S1 ('MetaSel ('Just "reverseRepeated") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (FoldR e))))

Methods

from :: Repeated e -> Rep (Repeated e) x #

to :: Rep (Repeated e) x -> Repeated e #

Read e => Read (Repeated e) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

Show e => Show (Repeated e) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

Methods

showsPrec :: Int -> Repeated e -> ShowS #

show :: Repeated e -> String #

showList :: [Repeated e] -> ShowS #

Eq e => Eq (Repeated e) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

Methods

(==) :: Repeated e -> Repeated e -> Bool #

(/=) :: Repeated e -> Repeated e -> Bool #

type Rep (Repeated e) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

type Rep (Repeated e) = D1 ('MetaData "Repeated" "Proto3.Wire.Encode.Repeated" "proto3-wire-1.4.6-CRlwbrcQnvz56vF5AH6Bds" 'False) (C1 ('MetaCons "ReverseRepeated" 'PrefixI 'True) (S1 ('MetaSel ('Just "countRepeated") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Int)) :*: S1 ('MetaSel ('Just "reverseRepeated") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (FoldR e))))

class ToRepeated (c :: TYPE cr) (e :: TYPE er) | c -> e where Source #

For each container type, specifies the optimal method for reverse iteration.

Methods

toRepeated :: c -> Repeated e Source #

Converts to a reverse iteration over the elements.

Instances

Instances details
ToRepeated IntSet Int Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

ToRepeated (Identity a :: Type) (a :: Type) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

ToRepeated (NonEmpty a :: Type) (a :: Type) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

ToRepeated (Seq a :: Type) (a :: Type) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

Methods

toRepeated :: Seq a -> Repeated a Source #

ToRepeated (Set a :: Type) (a :: Type) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

Methods

toRepeated :: Set a -> Repeated a Source #

ToRepeated (Vector a :: Type) (a :: Type) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

Methods

toRepeated :: Vector a -> Repeated a Source #

Storable a => ToRepeated (Vector a :: Type) (a :: Type) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

Methods

toRepeated :: Vector a -> Repeated a Source #

Unbox a => ToRepeated (Vector a :: Type) (a :: Type) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

Methods

toRepeated :: Vector a -> Repeated a Source #

ToRepeated ([a] :: Type) (a :: Type) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

Methods

toRepeated :: [a] -> Repeated a Source #

ToRepeated (IntMap a :: Type) ((Int, a) :: Type) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

Methods

toRepeated :: IntMap a -> Repeated (Int, a) Source #

ToRepeated (Repeated e :: Type) (e :: TYPE er) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

ToRepeated (Map k a :: Type) ((k, a) :: Type) Source # 
Instance details

Defined in Proto3.Wire.Encode.Repeated

Methods

toRepeated :: Map k a -> Repeated (k, a) Source #

mapRepeated :: ToRepeated c e => (e -> a) -> c -> Repeated a Source #

A convenience function that maps a function over a sequence, provided that the relevant types are all lifted.