Protobuf.Internal.Prelude
- Package
- purescript-protobuf
- Repository
- xc-jp/purescript-protobuf
The prelude for generated code.
Re-exports from Control.Alt
Re-exports from Control.Monad.Rec.Class
#MonadRec Source
class MonadRec :: (Type -> Type) -> Constraint
class (Monad m) <= MonadRec m
This type class captures those monads which support tail recursion in constant stack space.
The tailRecM
function takes a step function, and applies that step
function recursively until a pure value of type b
is found.
Instances are provided for standard monad transformers.
For example:
loopWriter :: Int -> WriterT (Additive Int) Effect Unit
loopWriter n = tailRecM go n
where
go 0 = do
traceM "Done!"
pure (Done unit)
go i = do
tell $ Additive i
pure (Loop (i - 1))
Instances
Re-exports from Data.Array
Re-exports from Data.ArrayBuffer.Builder
#PutM Source
type PutM :: (Type -> Type) -> Type -> Type
type PutM = WriterT Builder
The PutM
monad is a WriterT Builder
transformer monad which
gives us do-notation for the Builder
monoid. The base monad must be
a MonadEffect
.
To append Builder
s in this monad call tell
, or any of the put*
functions in this module.
Re-exports from Data.ArrayBuffer.Types
#DataView Source
data DataView
Represents a JS DataView on an ArrayBuffer (a slice into the ArrayBuffer)
#ByteLength Source
type ByteLength = Int
Length in bytes of a DataView or ArrayBuffer
Re-exports from Data.Bounded
#Bounded Source
Re-exports from Data.Bounded.Generic
#genericTop Source
genericTop :: forall a rep. Generic a rep => GenericTop rep => a
A Generic
implementation of the top
member from the Bounded
type class.
#genericBottom Source
genericBottom :: forall a rep. Generic a rep => GenericBottom rep => a
A Generic
implementation of the bottom
member from the Bounded
type class.
Re-exports from Data.Enum
#BoundedEnum Source
class (Bounded a, Enum a) <= BoundedEnum a
Type class for finite enumerations.
This should not be considered a part of a numeric hierarchy, as in Haskell.
Rather, this is a type class for small, ordered sum types with
statically-determined cardinality and the ability to easily compute
successor and predecessor elements like DayOfWeek
.
Laws:
succ bottom >>= succ >>= succ ... succ [cardinality - 1 times] == top
pred top >>= pred >>= pred ... pred [cardinality - 1 times] == bottom
forall a > bottom: pred a >>= succ == Just a
forall a < top: succ a >>= pred == Just a
forall a > bottom: fromEnum <$> pred a = pred (fromEnum a)
forall a < top: fromEnum <$> succ a = succ (fromEnum a)
e1 `compare` e2 == fromEnum e1 `compare` fromEnum e2
toEnum (fromEnum a) = Just a
Instances
#Enum Source
class (Ord a) <= Enum a
Type class for enumerations.
Laws:
- Successor:
all (a < _) (succ a)
- Predecessor:
all (_ < a) (pred a)
- Succ retracts pred:
pred >=> succ >=> pred = pred
- Pred retracts succ:
succ >=> pred >=> succ = succ
- Non-skipping succ:
b <= a || any (_ <= b) (succ a)
- Non-skipping pred:
a <= b || any (b <= _) (pred a)
The retraction laws can intuitively be understood as saying that succ
is
the opposite of pred
; if you apply succ
and then pred
to something,
you should end up with what you started with (although of course this
doesn't apply if you tried to succ
the last value in an enumeration and
therefore got Nothing
out).
The non-skipping laws can intuitively be understood as saying that succ
shouldn't skip over any elements of your type. For example, without the
non-skipping laws, it would be permissible to write an Enum Int
instance
where succ x = Just (x+2)
, and similarly pred x = Just (x-2)
.
Instances
Re-exports from Data.Enum.Generic
#genericSucc Source
genericSucc :: forall a rep. Generic a rep => GenericEnum rep => a -> Maybe a
A Generic
implementation of the succ
member from the Enum
type class.
#genericPred Source
genericPred :: forall a rep. Generic a rep => GenericEnum rep => a -> Maybe a
A Generic
implementation of the pred
member from the Enum
type class.
#genericCardinality Source
genericCardinality :: forall a rep. Generic a rep => GenericBoundedEnum rep => Cardinality a
A Generic
implementation of the cardinality
member from the
BoundedEnum
type class.
Re-exports from Data.Eq
#Eq Source
class Eq a where
The Eq
type class represents types which support decidable equality.
Eq
instances should satisfy the following laws:
- Reflexivity:
x == x = true
- Symmetry:
x == y = y == x
- Transitivity: if
x == y
andy == z
thenx == z
Note: The Number
type is not an entirely law abiding member of this
class due to the presence of NaN
, since NaN /= NaN
. Additionally,
computing with Number
can result in a loss of precision, so sometimes
values that should be equivalent are not.
Members
Instances
Re-exports from Data.Float32
Re-exports from Data.Function
#flip Source
flip :: forall a b c. (a -> b -> c) -> b -> a -> c
Given a function that takes two arguments, applies the arguments to the function in a swapped order.
flip append "1" "2" == append "2" "1" == "21"
const 1 "two" == 1
flip const 1 "two" == const "two" 1 == "two"
Re-exports from Data.Generic.Rep
#Generic Source
class Generic a rep | a -> rep
The Generic
class asserts the existence of a type function from types
to their representations using the type constructors defined in this module.
Re-exports from Data.Int64
Re-exports from Data.Maybe
#Maybe Source
data Maybe a
The Maybe
type is used to represent optional values and can be seen as
something like a type-safe null
, where Nothing
is null
and Just x
is the non-null value x
.
Constructors
Instances
Functor Maybe
The
Functor
instance allows functions to transform the contents of aJust
with the<$>
operator:f <$> Just x == Just (f x)
Nothing
values are left untouched:f <$> Nothing == Nothing
Apply Maybe
The
Apply
instance allows functions contained within aJust
to transform a value contained within aJust
using theapply
operator:Just f <*> Just x == Just (f x)
Nothing
values are left untouched:Just f <*> Nothing == Nothing Nothing <*> Just x == Nothing
Combining
Functor
's<$>
withApply
's<*>
can be used transform a pure function to takeMaybe
-typed arguments sof :: a -> b -> c
becomesf :: Maybe a -> Maybe b -> Maybe c
:f <$> Just x <*> Just y == Just (f x y)
The
Nothing
-preserving behaviour of both operators means the result of an expression like the above but where any one of the values isNothing
means the whole result becomesNothing
also:f <$> Nothing <*> Just y == Nothing f <$> Just x <*> Nothing == Nothing f <$> Nothing <*> Nothing == Nothing
Applicative Maybe
The
Applicative
instance enables lifting of values intoMaybe
with thepure
function:pure x :: Maybe _ == Just x
Combining
Functor
's<$>
withApply
's<*>
andApplicative
'spure
can be used to pass a mixture ofMaybe
and non-Maybe
typed values to a function that does not usually expect them, by usingpure
for any value that is not alreadyMaybe
typed:f <$> Just x <*> pure y == Just (f x y)
Even though
pure = Just
it is recommended to usepure
in situations like this as it allows the choice ofApplicative
to be changed later without having to go through and replaceJust
with a new constructor.Alt Maybe
The
Alt
instance allows for a choice to be made between twoMaybe
values with the<|>
operator, where the firstJust
encountered is taken.Just x <|> Just y == Just x Nothing <|> Just y == Just y Nothing <|> Nothing == Nothing
Plus Maybe
The
Plus
instance provides a defaultMaybe
value:empty :: Maybe _ == Nothing
Alternative Maybe
The
Alternative
instance guarantees that there are bothApplicative
andPlus
instances forMaybe
.Bind Maybe
The
Bind
instance allows sequencing ofMaybe
values and functions that return aMaybe
by using the>>=
operator:Just x >>= f = f x Nothing >>= f = Nothing
Monad Maybe
The
Monad
instance guarantees that there are bothApplicative
andBind
instances forMaybe
. This also enables thedo
syntactic sugar:do x' <- x y' <- y pure (f x' y')
Which is equivalent to:
x >>= (\x' -> y >>= (\y' -> pure (f x' y')))
Which is equivalent to:
case x of Nothing -> Nothing Just x' -> case y of Nothing -> Nothing Just y' -> Just (f x' y')
Extend Maybe
The
Extend
instance allows sequencing ofMaybe
values and functions that accept aMaybe a
and return a non-Maybe
result using the<<=
operator.f <<= Nothing = Nothing f <<= x = Just (f x)
Invariant Maybe
(Semigroup a) => Semigroup (Maybe a)
The
Semigroup
instance enables use of the operator<>
onMaybe
values whenever there is aSemigroup
instance for the type theMaybe
contains. The exact behaviour of<>
depends on the "inner"Semigroup
instance, but generally captures the notion of appending or combining things.Just x <> Just y = Just (x <> y) Just x <> Nothing = Just x Nothing <> Just y = Just y Nothing <> Nothing = Nothing
(Semigroup a) => Monoid (Maybe a)
(Semiring a) => Semiring (Maybe a)
(Eq a) => Eq (Maybe a)
The
Eq
instance allowsMaybe
values to be checked for equality with==
and inequality with/=
whenever there is anEq
instance for the type theMaybe
contains.Eq1 Maybe
(Ord a) => Ord (Maybe a)
The
Ord
instance allowsMaybe
values to be compared withcompare
,>
,>=
,<
and<=
whenever there is anOrd
instance for the type theMaybe
contains.Nothing
is considered to be less than anyJust
value.Ord1 Maybe
(Bounded a) => Bounded (Maybe a)
(Show a) => Show (Maybe a)
The
Show
instance allowsMaybe
values to be rendered as a string withshow
whenever there is anShow
instance for the type theMaybe
contains.Generic (Maybe a) _
#maybe Source
maybe :: forall a b. b -> (a -> b) -> Maybe a -> b
Takes a default value, a function, and a Maybe
value. If the Maybe
value is Nothing
the default value is returned, otherwise the function
is applied to the value inside the Just
and the result is returned.
maybe x f Nothing == x
maybe x f (Just y) == f y
Re-exports from Data.Newtype
#Newtype Source
class (Coercible t a) <= Newtype t a | t -> a
A type class for newtype
s to enable convenient wrapping and unwrapping,
and the use of the other functions in this module.
The compiler can derive instances of Newtype
automatically:
newtype EmailAddress = EmailAddress String
derive instance newtypeEmailAddress :: Newtype EmailAddress _
Note that deriving for Newtype
instances requires that the type be
defined as newtype
rather than data
declaration (even if the data
structurally fits the rules of a newtype
), and the use of a wildcard for
the wrapped type.
Instances
Re-exports from Data.Ord
#Ord Source
class (Eq a) <= Ord a
The Ord
type class represents types which support comparisons with a
total order.
Ord
instances should satisfy the laws of total orderings:
- Reflexivity:
a <= a
- Antisymmetry: if
a <= b
andb <= a
thena == b
- Transitivity: if
a <= b
andb <= c
thena <= c
Note: The Number
type is not an entirely law abiding member of this
class due to the presence of NaN
, since NaN <= NaN
evaluates to false
Instances
Re-exports from Data.Ord.Generic
#genericCompare Source
genericCompare :: forall a rep. Generic a rep => GenericOrd rep => a -> a -> Ordering
A Generic
implementation of the compare
member from the Ord
type class.
Re-exports from Data.Semigroup
Re-exports from Data.Show
#Show Source
class Show a
The Show
type class represents those types which can be converted into
a human-readable String
representation.
While not required, it is recommended that for any expression x
, the
string show x
be executable PureScript code which evaluates to the same
value as the expression x
.
Instances
Re-exports from Data.Show.Generic
#genericShow Source
genericShow :: forall a rep. Generic a rep => GenericShow rep => a -> String
A Generic
implementation of the show
member from the Show
type class.
Re-exports from Data.String
Re-exports from Data.Traversable
#traverse_ Source
traverse_ :: forall a b f m. Applicative m => Foldable f => (a -> m b) -> f a -> m Unit
Traverse a data structure, performing some effects encoded by an
Applicative
functor at each value, ignoring the final result.
For example:
traverse_ print [1, 2, 3]
Re-exports from Data.Tuple
#Tuple Source
data Tuple a b
A simple product type for wrapping a pair of component values.
Constructors
Tuple a b
Instances
(Show a, Show b) => Show (Tuple a b)
Allows
Tuple
s to be rendered as a string withshow
whenever there areShow
instances for both component types.(Eq a, Eq b) => Eq (Tuple a b)
Allows
Tuple
s to be checked for equality with==
and/=
whenever there areEq
instances for both component types.(Eq a) => Eq1 (Tuple a)
(Ord a, Ord b) => Ord (Tuple a b)
Allows
Tuple
s to be compared withcompare
,>
,>=
,<
and<=
whenever there areOrd
instances for both component types. To obtain the result, thefst
s arecompare
d, and if they areEQ
ual, thesnd
s arecompare
d.(Ord a) => Ord1 (Tuple a)
(Bounded a, Bounded b) => Bounded (Tuple a b)
Semigroupoid Tuple
(Semigroup a, Semigroup b) => Semigroup (Tuple a b)
The
Semigroup
instance enables use of the associative operator<>
onTuple
s whenever there areSemigroup
instances for the component types. The<>
operator is applied pairwise, so:(Tuple a1 b1) <> (Tuple a2 b2) = Tuple (a1 <> a2) (b1 <> b2)
(Monoid a, Monoid b) => Monoid (Tuple a b)
(Semiring a, Semiring b) => Semiring (Tuple a b)
(Ring a, Ring b) => Ring (Tuple a b)
(CommutativeRing a, CommutativeRing b) => CommutativeRing (Tuple a b)
(HeytingAlgebra a, HeytingAlgebra b) => HeytingAlgebra (Tuple a b)
(BooleanAlgebra a, BooleanAlgebra b) => BooleanAlgebra (Tuple a b)
Functor (Tuple a)
The
Functor
instance allows functions to transform the contents of aTuple
with the<$>
operator, applying the function to the second component, so:f <$> (Tuple x y) = Tuple x (f y)
Generic (Tuple a b) _
Invariant (Tuple a)
(Semigroup a) => Apply (Tuple a)
The
Apply
instance allows functions to transform the contents of aTuple
with the<*>
operator whenever there is aSemigroup
instance for thefst
component, so:(Tuple a1 f) <*> (Tuple a2 x) == Tuple (a1 <> a2) (f x)
(Monoid a) => Applicative (Tuple a)
(Semigroup a) => Bind (Tuple a)
(Monoid a) => Monad (Tuple a)
Extend (Tuple a)
Comonad (Tuple a)
(Lazy a, Lazy b) => Lazy (Tuple a b)
Re-exports from Data.UInt
Re-exports from Data.UInt64
Re-exports from Effect.Class
#MonadEffect Source
class MonadEffect :: (Type -> Type) -> Constraint
class (Monad m) <= MonadEffect m
The MonadEffect
class captures those monads which support native effects.
Instances are provided for Effect
itself, and the standard monad
transformers.
liftEffect
can be used in any appropriate monad transformer stack to lift an
action of type Effect a
into the monad.
Instances
Re-exports from Parsing
#ParserT Source
newtype ParserT :: Type -> (Type -> Type) -> Type -> Type
newtype ParserT s m a
The Parser s
monad with a monad transformer parameter m
.
Instances
Lazy (ParserT s m a)
(Semigroup a) => Semigroup (ParserT s m a)
(Monoid a) => Monoid (ParserT s m a)
Functor (ParserT s m)
Apply (ParserT s m)
Applicative (ParserT s m)
Bind (ParserT s m)
Monad (ParserT s m)
MonadRec (ParserT s m)
(MonadState t m) => MonadState t (ParserT s m)
(MonadAsk r m) => MonadAsk r (ParserT s m)
(MonadReader r m) => MonadReader r (ParserT s m)
MonadThrow ParseError (ParserT s m)
MonadError ParseError (ParserT s m)
Alt (ParserT s m)
The alternative
Alt
instance provides thealt
combinator<|>
.The expression
p_left <|> p_right
will first try thep_left
parser and if that fails and consumes no input then it will try thep_right
parser.While we are parsing down the
p_left
branch we may reach a point where we know this is the correct branch, but we cannot parse further. At that point we want to fail the entire parse instead of trying thep_right
branch.For example, consider this
fileParser
which can parse either an HTML file that begins with<html>
or a shell script file that begins with#!
.fileParser = string "<html>" *> parseTheRestOfTheHtml <|> string "#!" *> parseTheRestOfTheScript
If we read a file from disk and run this
fileParser
on it and thestring "<html>"
parser succeeds, then we know that the first branch is the correct branch, so we want to commit to the first branch. Even if theparseTheRestOfTheHtml
parser fails we don’t want to try the second branch.To control the point at which we commit to the
p_left
branch use thetry
combinator and thelookAhead
combinator and theconsume
function.The
alt
combinator works this way because it gives us good localized error messages while also allowing an efficient implementation. See Parsec: Direct Style Monadic Parser Combinators For The Real World section 2.3 Backtracking.Plus (ParserT s m)
Alternative (ParserT s m)
MonadPlus (ParserT s m)
MonadTrans (ParserT s)
Re-exports from Prelude
#Unit Source
data Unit
The Unit
type has a single inhabitant, called unit
. It represents
values with no computational content.
Unit
is often used, wrapped in a monadic type constructor, as the
return type of a computation where only the effects are important.
When returning a value of type Unit
from an FFI function, it is
recommended to use undefined
, or not return a value at all.
#pure Source
pure :: forall f a. Applicative f => a -> f a
#(>>>) Source
Operator alias for Control.Semigroupoid.composeFlipped (right-associative / precedence 9)
#($) Source
Operator alias for Data.Function.apply (right-associative / precedence 0)
Applies a function to an argument: the reverse of (#)
.
length $ groupBy productCategory $ filter isInStock $ products
is equivalent to:
length (groupBy productCategory (filter isInStock products))
Or another alternative equivalent, applying chain of composed functions to a value:
length <<< groupBy productCategory <<< filter isInStock $ products
Re-exports from Prim.Row
#Nub
#Union
Re-exports from Protobuf.Internal.Common
#FieldNumber Source
type FieldNumber = UInt
#Bytes Source
newtype Bytes
Representation of a bytes Scalar Value Type field.
On a message which has been decoded,
The wrapped DataBuff
will usually be a DataView
.
In that case, the DataView
is a view into the
received message I/O buffer.
For messages which you intend to encode,
You may set the DataBuff
to DataView
or ArrayBuffer
,
whichever seems best.
The ArrayBuffer
and DataView
are mutable, so be careful not to mutate
them if anything might read them again. Here we trade off typechecker
guarantees for implementation simplicity.
Constructors
Instances
#Default Source
class Default a where
In Protobuf, zero values are “default values” and have special semantics.
Members
Instances
#toDefault Source
toDefault :: forall a. Default a => Maybe a -> a
Turns Nothing
into a “default” (zero) value.
The Protobuf spec requires that a no presence field set to its “default” (zero) value must not be serialized to the wire.
When receiving messages we can use this function to interpret a missing no presence field as a “default” value.
#fromDefault Source
fromDefault :: forall a. Default a => Eq a => a -> Maybe a
Turns a “default” (zero) value into Nothing
.
Re-exports from Protobuf.Internal.Decode
#decodeVarint32 Source
decodeVarint32 :: forall m. MonadEffect m => ParserT DataView m UInt
There is no varint32
in the Protbuf spec, this is
just a performance-improving assumption we make
in cases where we would be surprised to see a number
larger than 32 bits, such as in field numbers.
We think this is worth the risk because UInt
is
represented as a native Javascript Number whereas
UInt64
is a composite library type, so we expect the
performance difference to be significant.
https://developers.google.com/protocol-buffers/docs/encoding#varints
#decodeUint64 Source
decodeUint64 :: forall m. MonadEffect m => ParserT DataView m UInt64
uint64 Scalar Value Type
#decodeUint32 Source
decodeUint32 :: forall m. MonadEffect m => ParserT DataView m UInt
uint32 Scalar Value Type
#decodeTag32 Source
decodeTag32 :: forall m. MonadEffect m => ParserT DataView m (Tuple FieldNumber WireType)
Parse the field number and wire type of the next field. https://developers.google.com/protocol-buffers/docs/encoding#structure
#decodeString Source
decodeString :: forall m. MonadEffect m => ParserT DataView m String
string Scalar Value Type
#decodeSint64 Source
decodeSint64 :: forall m. MonadEffect m => ParserT DataView m Int64
sint64 Scalar Value Type
#decodeSint32 Source
decodeSint32 :: forall m. MonadEffect m => ParserT DataView m Int
sint32 Scalar Value Type
#decodeSfixed64Array Source
decodeSfixed64Array :: forall m. MonadEffect m => ByteLength -> ParserT DataView m (Array Int64)
repeated packed sfixed64
Equivalent to manyLength decodeSfixed64
, but specialized so it’s faster.
#decodeSfixed64 Source
decodeSfixed64 :: forall m. MonadEffect m => ParserT DataView m Int64
sfixed64 Scalar Value Type
#decodeSfixed32Array Source
decodeSfixed32Array :: forall m. MonadEffect m => ByteLength -> ParserT DataView m (Array Int)
repeated packed sfixed32
Equivalent to manyLength decodeSfixed32
, but specialized so it’s faster.
#decodeSfixed32 Source
decodeSfixed32 :: forall m. MonadEffect m => ParserT DataView m Int
sfixed32 Scalar Value Type
#decodeInt64 Source
decodeInt64 :: forall m. MonadEffect m => ParserT DataView m Int64
int64 Scalar Value Type
#decodeInt32 Source
decodeInt32 :: forall m. MonadEffect m => ParserT DataView m Int
int32 Scalar Value Type
#decodeFloatArray Source
decodeFloatArray :: forall m. MonadEffect m => ByteLength -> ParserT DataView m (Array Float32)
repeated packed float
Equivalent to manyLength decodeFloat
, but specialized so it’s faster.
#decodeFloat Source
decodeFloat :: forall m. MonadEffect m => ParserT DataView m Float32
float Scalar Value Type
#decodeFixed64Array Source
decodeFixed64Array :: forall m. MonadEffect m => ByteLength -> ParserT DataView m (Array UInt64)
repeated packed fixed64
Equivalent to manyLength decodeFixed64
, but specialized so it’s faster.
#decodeFixed64 Source
decodeFixed64 :: forall m. MonadEffect m => ParserT DataView m UInt64
fixed64 Scalar Value Type
#decodeFixed32Array Source
decodeFixed32Array :: forall m. MonadEffect m => ByteLength -> ParserT DataView m (Array UInt)
repeated packed fixed32
Equivalent to manyLength decodeFixed32
, but specialized so it’s faster.
#decodeFixed32 Source
decodeFixed32 :: forall m. MonadEffect m => ParserT DataView m UInt
fixed32 Scalar Value Type
#decodeDoubleArray Source
decodeDoubleArray :: forall m. MonadEffect m => ByteLength -> ParserT DataView m (Array Number)
repeated packed double
Equivalent to manyLength decodeDouble
, but specialized so it’s faster.
#decodeDouble Source
decodeDouble :: forall m. MonadEffect m => ParserT DataView m Number
double Scalar Value Type
#decodeBytes Source
decodeBytes :: forall m. MonadEffect m => ParserT DataView m Bytes
bytes Scalar Value Type
#decodeBool Source
decodeBool :: forall m. MonadEffect m => ParserT DataView m Boolean
bool Scalar Value Type
Re-exports from Protobuf.Internal.Encode
#encodeVarint64 Source
encodeVarint64 :: forall m. MonadEffect m => UInt64 -> PutM m Unit
#encodeVarint32 Source
encodeVarint32 :: forall m. MonadEffect m => UInt -> PutM m Unit
There is no varint32
in the Protbuf spec, this is
just a performance-improving assumption we make
in cases where we would be surprised to see a number
larger than 32 bits, such as in field numbers.
We think this is worth the risk because UInt
is
represented as a native Javascript Number whereas
UInt64
is a composite library type, so we expect the
performance difference to be significant.
https://developers.google.com/protocol-buffers/docs/encoding#varints
#encodeUint64Field Source
encodeUint64Field :: forall m. MonadEffect m => FieldNumber -> UInt64 -> PutM m Unit
#encodeUint64 Source
encodeUint64 :: forall m. MonadEffect m => UInt64 -> PutM m Unit
uint64 Scalar Value Type
#encodeUint32Field Source
encodeUint32Field :: forall m. MonadEffect m => FieldNumber -> UInt -> PutM m Unit
#encodeUint32 Source
encodeUint32 :: forall m. MonadEffect m => UInt -> PutM m Unit
uint32 Scalar Value Type
#encodeTag32 Source
encodeTag32 :: forall m. MonadEffect m => FieldNumber -> WireType -> PutM m Unit
https://developers.google.com/protocol-buffers/docs/encoding#structure
#encodeStringField Source
encodeStringField :: forall m. MonadEffect m => FieldNumber -> String -> PutM m Unit
string Scalar Value Type
#encodeSint64Field Source
encodeSint64Field :: forall m. MonadEffect m => FieldNumber -> Int64 -> PutM m Unit
#encodeSint64 Source
encodeSint64 :: forall m. MonadEffect m => Int64 -> PutM m Unit
sint64 Scalar Value Type
#encodeSint32Field Source
encodeSint32Field :: forall m. MonadEffect m => FieldNumber -> Int -> PutM m Unit
#encodeSint32 Source
encodeSint32 :: forall m. MonadEffect m => Int -> PutM m Unit
sint32 Scalar Value Type
#encodeSfixed64Field Source
encodeSfixed64Field :: forall m. MonadEffect m => FieldNumber -> Int64 -> PutM m Unit
#encodeSfixed64 Source
encodeSfixed64 :: forall m. MonadEffect m => Int64 -> PutM m Unit
sfixed64 Scalar Value Type
#encodeSfixed32Field Source
encodeSfixed32Field :: forall m. MonadEffect m => FieldNumber -> Int -> PutM m Unit
#encodeSfixed32 Source
encodeSfixed32 :: forall m. MonadEffect m => Int -> PutM m Unit
sfixed32 Scalar Value Type
#encodeInt64Field Source
encodeInt64Field :: forall m. MonadEffect m => FieldNumber -> Int64 -> PutM m Unit
#encodeInt64 Source
encodeInt64 :: forall m. MonadEffect m => Int64 -> PutM m Unit
int64 Scalar Value Type
#encodeInt32Field Source
encodeInt32Field :: forall m. MonadEffect m => FieldNumber -> Int -> PutM m Unit
#encodeInt32 Source
encodeInt32 :: forall m. MonadEffect m => Int -> PutM m Unit
int32 Scalar Value Type
#encodeFloatField Source
encodeFloatField :: forall m. MonadEffect m => FieldNumber -> Float32 -> PutM m Unit
#encodeFloat Source
encodeFloat :: forall m. MonadEffect m => Float32 -> PutM m Unit
float Scalar Value Type
#encodeFixed64Field Source
encodeFixed64Field :: forall m. MonadEffect m => FieldNumber -> UInt64 -> PutM m Unit
#encodeFixed64 Source
encodeFixed64 :: forall m. MonadEffect m => UInt64 -> PutM m Unit
fixed64 Scalar Value Type
#encodeFixed32Field Source
encodeFixed32Field :: forall m. MonadEffect m => FieldNumber -> UInt -> PutM m Unit
#encodeFixed32 Source
encodeFixed32 :: forall m. MonadEffect m => UInt -> PutM m Unit
fixed32 Scalar Value Type
#encodeDoubleField Source
encodeDoubleField :: forall m. MonadEffect m => FieldNumber -> Number -> PutM m Unit
#encodeDouble Source
encodeDouble :: forall m. MonadEffect m => Number -> PutM m Unit
double Scalar Value Type
#encodeBytesField Source
encodeBytesField :: forall m. MonadEffect m => FieldNumber -> Bytes -> PutM m Unit
bytes Scalar Value Type
#encodeBuilder Source
encodeBuilder :: forall m. MonadEffect m => FieldNumber -> Builder -> PutM m Unit
tell
with a tag and a length delimit.
#encodeBoolField Source
encodeBoolField :: forall m. MonadEffect m => FieldNumber -> Boolean -> PutM m Unit
#encodeBool Source
encodeBool :: forall m. MonadEffect m => Boolean -> PutM m Unit
bool Scalar Value Type
Re-exports from Protobuf.Internal.Runtime
#UnknownField Source
data UnknownField
A message field value from an unknown .proto
definition.
See Message Structure for an explanation.
UnknownVarInt
UseProtobuf.Internal.Decode.decodeZigzag64
to interpret this as a signed integer.UnknownLenDel
holds a variable-lengthBytes
.UnknownBits64
must holdBytes
of length 8.UnknownBits32
must holdBytes
of length 4.
See the modules Protobuf.Internal.Encode
and Protobuf.Internal.Decode for ways to operate on the Bytes
.
Constructors
UnknownVarInt FieldNumber UInt64
UnknownBits64 FieldNumber Bytes
UnknownLenDel FieldNumber Bytes
UnknownBits32 FieldNumber Bytes
Instances
#FieldNumberInt Source
type FieldNumberInt = Int
We want an Int FieldNumber to pass to parseField so that we can pattern match on Int literals. UInt doesn't export any constructors, so we can’t pattern match on it.
#putRepeated Source
putRepeated :: forall m a. MonadEffect m => FieldNumberInt -> Array a -> (FieldNumber -> a -> PutM m Unit) -> PutM m Unit
#putPacked Source
putPacked :: forall m a. MonadEffect m => FieldNumberInt -> Array a -> (a -> PutM m Unit) -> PutM m Unit
#putOptional Source
putOptional :: forall m a. MonadEffect m => FieldNumberInt -> Maybe a -> (a -> Boolean) -> (FieldNumber -> a -> PutM m Unit) -> PutM m Unit
#putLenDel Source
putLenDel :: forall m a. MonadEffect m => (a -> PutM m Unit) -> FieldNumber -> a -> PutM m Unit
#putFieldUnknown Source
putFieldUnknown :: forall m. MonadEffect m => UnknownField -> PutM m Unit
#putEnumField Source
putEnumField :: forall m a. MonadEffect m => BoundedEnum a => FieldNumber -> a -> PutM m Unit
#putEnum Source
putEnum :: forall m a. MonadEffect m => BoundedEnum a => a -> PutM m Unit
#parseMessage Source
parseMessage :: forall m a r. MonadEffect m => MonadRec m => (Record r -> a) -> (Record r) -> (FieldNumberInt -> WireType -> ParserT DataView m (Builder (Record r) (Record r))) -> ByteLength -> ParserT DataView m a
The parseField argument is a parser which returns a Record builder which, when applied to a Record, will modify the Record to add the parsed field.
#parseLenDel Source
parseLenDel :: forall m a. MonadEffect m => (Int -> ParserT DataView m a) -> ParserT DataView m a
Parse a length, then call a parser which takes one length as its argument.
#parseFieldUnknown Source
parseFieldUnknown :: forall m r. MonadEffect m => Int -> WireType -> ParserT DataView m (Builder ({ __unknown_fields :: Array UnknownField | r }) ({ __unknown_fields :: Array UnknownField | r }))
Parse and preserve an unknown field.
#parseEnum Source
parseEnum :: forall m a. MonadEffect m => BoundedEnum a => ParserT DataView m a
#manyLength Source
manyLength :: forall m a. MonadEffect m => MonadRec m => ParserT DataView m a -> ByteLength -> ParserT DataView m (Array a)
Call a parser repeatedly until exactly N bytes have been consumed. Will fail if too many bytes are consumed.
Re-exports from Record
Re-exports from Record.Builder
#Builder Source
newtype Builder a b
A Builder
can be used to build
a record by incrementally adding
fields in-place, instead of using insert
and repeatedly generating new
immutable records which need to be garbage collected.
The mutations accumulated in a Builder
are safe because intermediate states can't be
observed. These mutations, then, are performed all-at-once in the build
function.
The Category
instance for Builder
can be used to compose builders.
For example:
build (insert x 42 >>> insert y "testing") {} :: { x :: Int, y :: String }
The
Bounded
Int
instance hastop :: Int
equal to 2^31 - 1, andbottom :: Int
equal to -2^31, since these are the largest and smallest integers representable by twos-complement 32-bit integers, respectively.