{-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies,
UndecidableInstances, GeneralizedNewtypeDeriving,
MultiParamTypeClasses, FlexibleContexts, FlexibleInstances,
PatternSynonyms, MagicHash, NoImplicitPrelude, DataKinds,
BangPatterns, TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-unused-imports#-}
{-# OPTIONS_GHC -fno-warn-duplicate-exports#-}
module Proto.Modules.Auth (Account(), Coin()) where
import qualified Data.ProtoLens.Runtime.Control.DeepSeq
as Control.DeepSeq
import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Prism
as Data.ProtoLens.Prism
import qualified Data.ProtoLens.Runtime.Prelude as Prelude
import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int
import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid
import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word
import qualified Data.ProtoLens.Runtime.Data.ProtoLens
as Data.ProtoLens
import qualified
Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes
as Data.ProtoLens.Encoding.Bytes
import qualified
Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing
as Data.ProtoLens.Encoding.Growing
import qualified
Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe
as Data.ProtoLens.Encoding.Parser.Unsafe
import qualified
Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire
as Data.ProtoLens.Encoding.Wire
import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field
as Data.ProtoLens.Field
import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum
as Data.ProtoLens.Message.Enum
import qualified
Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types
as Data.ProtoLens.Service.Types
import qualified Data.ProtoLens.Runtime.Lens.Family2
as Lens.Family2
import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked
as Lens.Family2.Unchecked
import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text
import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map
import qualified Data.ProtoLens.Runtime.Data.ByteString
as Data.ByteString
import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8
as Data.ByteString.Char8
import qualified Data.ProtoLens.Runtime.Data.Text.Encoding
as Data.Text.Encoding
import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector
import qualified Data.ProtoLens.Runtime.Data.Vector.Generic
as Data.Vector.Generic
import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed
as Data.Vector.Unboxed
import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read
data Account = Account{_Account'coins ::
!(Data.Vector.Vector Coin),
_Account'nonce :: !Data.Word.Word64,
_Account'_unknownFields :: !Data.ProtoLens.FieldSet}
deriving (Prelude.Eq, Prelude.Ord)
instance Prelude.Show Account where
showsPrec _ __x __s
= Prelude.showChar '{'
(Prelude.showString (Data.ProtoLens.showMessageShort __x)
(Prelude.showChar '}' __s))
instance Data.ProtoLens.Field.HasField Account "coins" ([Coin])
where
fieldOf _
= (Lens.Family2.Unchecked.lens _Account'coins
(\ x__ y__ -> x__{_Account'coins = y__}))
Prelude..
Lens.Family2.Unchecked.lens Data.Vector.Generic.toList
(\ _ y__ -> Data.Vector.Generic.fromList y__)
instance Data.ProtoLens.Field.HasField Account "vec'coins"
(Data.Vector.Vector Coin)
where
fieldOf _
= (Lens.Family2.Unchecked.lens _Account'coins
(\ x__ y__ -> x__{_Account'coins = y__}))
Prelude.. Prelude.id
instance Data.ProtoLens.Field.HasField Account "nonce"
(Data.Word.Word64)
where
fieldOf _
= (Lens.Family2.Unchecked.lens _Account'nonce
(\ x__ y__ -> x__{_Account'nonce = y__}))
Prelude.. Prelude.id
instance Data.ProtoLens.Message Account where
messageName _ = Data.Text.pack "Auth.Account"
fieldsByTag
= let coins__field_descriptor
= Data.ProtoLens.FieldDescriptor "coins"
(Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::
Data.ProtoLens.FieldTypeDescriptor Coin)
(Data.ProtoLens.RepeatedField Data.ProtoLens.Unpacked
(Data.ProtoLens.Field.field @"coins"))
:: Data.ProtoLens.FieldDescriptor Account
nonce__field_descriptor
= Data.ProtoLens.FieldDescriptor "nonce"
(Data.ProtoLens.ScalarField Data.ProtoLens.UInt64Field ::
Data.ProtoLens.FieldTypeDescriptor Data.Word.Word64)
(Data.ProtoLens.PlainField Data.ProtoLens.Optional
(Data.ProtoLens.Field.field @"nonce"))
:: Data.ProtoLens.FieldDescriptor Account
in
Data.Map.fromList
[(Data.ProtoLens.Tag 1, coins__field_descriptor),
(Data.ProtoLens.Tag 2, nonce__field_descriptor)]
unknownFields
= Lens.Family2.Unchecked.lens _Account'_unknownFields
(\ x__ y__ -> x__{_Account'_unknownFields = y__})
defMessage
= Account{_Account'coins = Data.Vector.Generic.empty,
_Account'nonce = Data.ProtoLens.fieldDefault,
_Account'_unknownFields = ([])}
parseMessage
= let loop ::
Account ->
Data.ProtoLens.Encoding.Growing.Growing Data.Vector.Vector
Data.ProtoLens.Encoding.Growing.RealWorld
Coin
-> Data.ProtoLens.Encoding.Bytes.Parser Account
loop x mutable'coins
= do end <- Data.ProtoLens.Encoding.Bytes.atEnd
if end then
do frozen'coins <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO
(Data.ProtoLens.Encoding.Growing.unsafeFreeze
mutable'coins)
let missing = [] in
if Prelude.null missing then Prelude.return () else
Prelude.fail
(("Missing required fields: ") Prelude.++
Prelude.show (missing :: ([Prelude.String])))
Prelude.return
(Lens.Family2.over Data.ProtoLens.unknownFields
(\ !t -> Prelude.reverse t)
(Lens.Family2.set (Data.ProtoLens.Field.field @"vec'coins")
frozen'coins
x))
else
do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt
case tag of
10 -> do !y <- (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt
Data.ProtoLens.Encoding.Bytes.isolate
(Prelude.fromIntegral len)
Data.ProtoLens.parseMessage)
Data.ProtoLens.Encoding.Bytes.<?> "coins"
v <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO
(Data.ProtoLens.Encoding.Growing.append
mutable'coins
y)
loop x v
16 -> do y <- (Data.ProtoLens.Encoding.Bytes.getVarInt)
Data.ProtoLens.Encoding.Bytes.<?> "nonce"
loop
(Lens.Family2.set (Data.ProtoLens.Field.field @"nonce") y
x)
mutable'coins
wire -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire
wire
loop
(Lens.Family2.over Data.ProtoLens.unknownFields
(\ !t -> (:) y t)
x)
mutable'coins
in
(do mutable'coins <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO
Data.ProtoLens.Encoding.Growing.new
loop Data.ProtoLens.defMessage mutable'coins)
Data.ProtoLens.Encoding.Bytes.<?> "Account"
buildMessage
= (\ _x ->
(Data.ProtoLens.Encoding.Bytes.foldMapBuilder
(\ _v ->
(Data.ProtoLens.Encoding.Bytes.putVarInt 10) Data.Monoid.<>
(((\ bs ->
(Data.ProtoLens.Encoding.Bytes.putVarInt
(Prelude.fromIntegral (Data.ByteString.length bs)))
Data.Monoid.<> Data.ProtoLens.Encoding.Bytes.putBytes bs))
Prelude.. Data.ProtoLens.encodeMessage)
_v)
(Lens.Family2.view (Data.ProtoLens.Field.field @"vec'coins") _x))
Data.Monoid.<>
(let _v
= Lens.Family2.view (Data.ProtoLens.Field.field @"nonce") _x
in
if (_v) Prelude.== Data.ProtoLens.fieldDefault then
Data.Monoid.mempty else
(Data.ProtoLens.Encoding.Bytes.putVarInt 16) Data.Monoid.<>
Data.ProtoLens.Encoding.Bytes.putVarInt _v)
Data.Monoid.<>
Data.ProtoLens.Encoding.Wire.buildFieldSet
(Lens.Family2.view Data.ProtoLens.unknownFields _x))
instance Control.DeepSeq.NFData Account where
rnf
= (\ x__ ->
Control.DeepSeq.deepseq (_Account'_unknownFields x__)
(Control.DeepSeq.deepseq (_Account'coins x__)
(Control.DeepSeq.deepseq (_Account'nonce x__) (()))))
data Coin = Coin{_Coin'denomination :: !Data.Text.Text,
_Coin'amount :: !Data.Word.Word64,
_Coin'_unknownFields :: !Data.ProtoLens.FieldSet}
deriving (Prelude.Eq, Prelude.Ord)
instance Prelude.Show Coin where
showsPrec _ __x __s
= Prelude.showChar '{'
(Prelude.showString (Data.ProtoLens.showMessageShort __x)
(Prelude.showChar '}' __s))
instance Data.ProtoLens.Field.HasField Coin "denomination"
(Data.Text.Text)
where
fieldOf _
= (Lens.Family2.Unchecked.lens _Coin'denomination
(\ x__ y__ -> x__{_Coin'denomination = y__}))
Prelude.. Prelude.id
instance Data.ProtoLens.Field.HasField Coin "amount"
(Data.Word.Word64)
where
fieldOf _
= (Lens.Family2.Unchecked.lens _Coin'amount
(\ x__ y__ -> x__{_Coin'amount = y__}))
Prelude.. Prelude.id
instance Data.ProtoLens.Message Coin where
messageName _ = Data.Text.pack "Auth.Coin"
fieldsByTag
= let denomination__field_descriptor
= Data.ProtoLens.FieldDescriptor "denomination"
(Data.ProtoLens.ScalarField Data.ProtoLens.StringField ::
Data.ProtoLens.FieldTypeDescriptor Data.Text.Text)
(Data.ProtoLens.PlainField Data.ProtoLens.Optional
(Data.ProtoLens.Field.field @"denomination"))
:: Data.ProtoLens.FieldDescriptor Coin
amount__field_descriptor
= Data.ProtoLens.FieldDescriptor "amount"
(Data.ProtoLens.ScalarField Data.ProtoLens.UInt64Field ::
Data.ProtoLens.FieldTypeDescriptor Data.Word.Word64)
(Data.ProtoLens.PlainField Data.ProtoLens.Optional
(Data.ProtoLens.Field.field @"amount"))
:: Data.ProtoLens.FieldDescriptor Coin
in
Data.Map.fromList
[(Data.ProtoLens.Tag 1, denomination__field_descriptor),
(Data.ProtoLens.Tag 2, amount__field_descriptor)]
unknownFields
= Lens.Family2.Unchecked.lens _Coin'_unknownFields
(\ x__ y__ -> x__{_Coin'_unknownFields = y__})
defMessage
= Coin{_Coin'denomination = Data.ProtoLens.fieldDefault,
_Coin'amount = Data.ProtoLens.fieldDefault,
_Coin'_unknownFields = ([])}
parseMessage
= let loop :: Coin -> Data.ProtoLens.Encoding.Bytes.Parser Coin
loop x
= do end <- Data.ProtoLens.Encoding.Bytes.atEnd
if end then
do let missing = [] in
if Prelude.null missing then Prelude.return () else
Prelude.fail
(("Missing required fields: ") Prelude.++
Prelude.show (missing :: ([Prelude.String])))
Prelude.return
(Lens.Family2.over Data.ProtoLens.unknownFields
(\ !t -> Prelude.reverse t)
x)
else
do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt
case tag of
10 -> do y <- (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt
Data.ProtoLens.Encoding.Bytes.getBytes
(Prelude.fromIntegral len)
Data.ProtoLens.Encoding.Bytes.runEither
(case Data.Text.Encoding.decodeUtf8' value of
Prelude.Left err -> Prelude.Left
(Prelude.show err)
Prelude.Right r -> Prelude.Right r))
Data.ProtoLens.Encoding.Bytes.<?> "denomination"
loop
(Lens.Family2.set
(Data.ProtoLens.Field.field @"denomination")
y
x)
16 -> do y <- (Data.ProtoLens.Encoding.Bytes.getVarInt)
Data.ProtoLens.Encoding.Bytes.<?> "amount"
loop
(Lens.Family2.set (Data.ProtoLens.Field.field @"amount")
y
x)
wire -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire
wire
loop
(Lens.Family2.over Data.ProtoLens.unknownFields
(\ !t -> (:) y t)
x)
in
(do loop Data.ProtoLens.defMessage)
Data.ProtoLens.Encoding.Bytes.<?> "Coin"
buildMessage
= (\ _x ->
(let _v
= Lens.Family2.view (Data.ProtoLens.Field.field @"denomination") _x
in
if (_v) Prelude.== Data.ProtoLens.fieldDefault then
Data.Monoid.mempty else
(Data.ProtoLens.Encoding.Bytes.putVarInt 10) Data.Monoid.<>
(((\ bs ->
(Data.ProtoLens.Encoding.Bytes.putVarInt
(Prelude.fromIntegral (Data.ByteString.length bs)))
Data.Monoid.<> Data.ProtoLens.Encoding.Bytes.putBytes bs))
Prelude.. Data.Text.Encoding.encodeUtf8)
_v)
Data.Monoid.<>
(let _v
= Lens.Family2.view (Data.ProtoLens.Field.field @"amount") _x
in
if (_v) Prelude.== Data.ProtoLens.fieldDefault then
Data.Monoid.mempty else
(Data.ProtoLens.Encoding.Bytes.putVarInt 16) Data.Monoid.<>
Data.ProtoLens.Encoding.Bytes.putVarInt _v)
Data.Monoid.<>
Data.ProtoLens.Encoding.Wire.buildFieldSet
(Lens.Family2.view Data.ProtoLens.unknownFields _x))
instance Control.DeepSeq.NFData Coin where
rnf
= (\ x__ ->
Control.DeepSeq.deepseq (_Coin'_unknownFields x__)
(Control.DeepSeq.deepseq (_Coin'denomination x__)
(Control.DeepSeq.deepseq (_Coin'amount x__) (()))))