git.iko.soy/rowtype-yoga/purescript-protobuf
on master help sign in
MonadRec
commit057f6a6d977b9bf65142765e46bc2978c647d46f authorJames Brock <jamesbrock@gmail.com> dateWed 14 Oct 2020, 21:44 (6 years ago) parent40734b5
4 files changed+68−55
src/Protobuf/Runtime.purs+31−21 src/ProtocPlugin/Main.purs+4−3 src/ProtocPlugin/descriptor.Google.Protobuf.purs+28−27 src/ProtocPlugin/plugin.Google.Protobuf.Compiler.purs+5−4
src/Protobuf/Runtime.purs+31−21
@@ -30,6 +30,7 @@ import Control.Monad.Trans.Class (lift)
3030import Control.Monad.Rec.Class (class MonadRec, tailRecM, Step(..))
3131import Control.Monad.ST as ST
3232import Data.Array (fromFoldable, snoc)
33+import Data.Array as A
3334import Data.Array.ST as Array.ST
3435import Data.ArrayBuffer.ArrayBuffer as AB
3536import Data.ArrayBuffer.Builder (PutM, subBuilder)
@@ -46,6 +47,7 @@ import Data.Symbol (SProxy(..))
4647import Data.Tuple (Tuple(..))
4748import Data.UInt (UInt)
4849import Data.UInt as UInt
50+import Effect (Effect)
4951import Effect.Class (class MonadEffect, liftEffect)
5052import Effect.Ref (Ref)
5153import Effect.Ref as Effect.Ref
@@ -64,6 +66,7 @@ import Text.Parsing.Parser.Pos (Position(..))
6466parseMessage
6567 :: forall m a r
6668 . MonadEffect m
69+ => MonadRec m
6770 => (Record r -> a)
6871 -> (Record r)
6972 -> (FieldNumberInt -> WireType -> ParserT DataView m (RecordB.Builder (Record r) (Record r)))
@@ -98,46 +101,53 @@ positionZero = do
98101manyLength
99102 :: forall m a
100103 . MonadEffect m
101− -- => MonadRec m -- ParserT is a MonadRec
104+ => MonadRec m
102105 => ParserT DataView m a
103106 -> Int -- byte length
104107 -> ParserT DataView m (Array a)
105108manyLength p len = do
106109 posBegin' <- positionZero
107− fromFoldable <$> go posBegin'
110+ -- fromFoldable <$> go posBegin'
108111 -- TODO It would be faster if we could accumulate the Array with
109112 -- https://pursuit.purescript.org/packages/purescript-arrays/5.3.1/docs/Data.Array.ST#v:push
110113 -- instead of copying from a List?
114+ ref <- lift $ liftEffect (Ref.new [] :: Effect (Ref (Array a)))
115+ begin posBegin' ref
116+ lift $ liftEffect $ Ref.read ref
111117 where
112118 -- https://github.com/purescript-contrib/purescript-parsing/blob/e801a0ef42f3211b1602a94a269eef7ce551423f/src/Text/Parsing/Parser/Combinators.purs#L188
113− go posBegin = do
114− pos <- positionZero
115− case compare (pos - posBegin) len of
116− GT -> fail "manyLength consumed too many bytes."
117− EQ -> pure Nil
118− LT -> do
119− x <- p
120− xs <- go posBegin
121− pure $ x:xs
122119
123− begin :: Int -> Ref (Array a) -> ParserT DataView m (Array a)
124− begin posBegin refArray = tailRecM go' unit
120+ -- go posBegin = do
121+ -- pos <- positionZero
122+ -- case compare (pos - posBegin) len of
123+ -- GT -> fail "manyLength consumed too many bytes."
124+ -- EQ -> pure Nil
125+ -- LT -> do
126+ -- x <- p
127+ -- xs <- go posBegin
128+ -- pure $ x:xs
129+
130+ begin :: Int -> Ref (Array a) -> ParserT DataView m Unit
131+ begin posBegin refArray = do
132+ tailRecM go unit
125133 where
126− go' :: Unit -> ParserT DataView m Unit
127− go' _ = do
134+ go :: Unit -> ParserT DataView m (Step Unit Unit)
135+ go _ = do
128136 pos <- positionZero
129137 case compare (pos - posBegin) len of
130138 GT -> fail "manyLength consumed too many bytes."
131139 EQ -> lift $ pure (Done unit)
132140 LT -> do
133141 x <- p
134− _ <- liftEffect $ Effect.Ref.modify_ (snocMutate x) refArray -- TODO we don't actually need Effect.Ref
142+ lift $ liftEffect $ Effect.Ref.modify_ (unsafeSnoc x) refArray -- TODO we don't actually need Effect.Ref
135143 lift $ pure (Loop unit)
136− snocMutate :: a -> Array a -> Array a
137− snocMutate x xs = ST.run $ do
138− xs' <- Array.ST.unsafeThaw xs
139− _ <- Array.ST.push x xs'
140− Array.ST.unsafeFreeze xs'
144+ unsafeSnoc :: a -> Array a -> Array a
145+ unsafeSnoc x = \xs -> ST.run
146+ ( do
147+ xs' <- Array.ST.unsafeThaw xs
148+ _ <- Array.ST.push x xs'
149+ Array.ST.unsafeFreeze xs'
150+ )
141151
142152
143153
src/ProtocPlugin/Main.purs+4−3
@@ -152,7 +152,8 @@ genFile proto_file (FileDescriptorProto
152152where
153153
154154import Prelude
155−import Effect.Class as Effect
155+import Effect.Class (class MonadEffect)
156+import Control.Monad.Rec.Class (class MonadRec)
156157import Record.Builder as Record.Builder
157158import Data.Array as Array
158159import Data.Bounded as Bounded
@@ -356,14 +357,14 @@ import Protobuf.Runtime as Runtime
356357 -- https://github.com/purescript/purescript/issues/2975#issuecomment-313650710
357358 , "instance show" <> tname <> " :: Show.Show " <> tname <> " where show x = Generic.Rep.Show.genericShow x"
358359 , ""
359− , "put" <> tname <> " :: forall m. Effect.MonadEffect m => " <> tname <> " -> ArrayBuffer.Builder.PutM m Unit.Unit"
360+ , "put" <> tname <> " :: forall m. MonadEffect m => " <> tname <> " -> ArrayBuffer.Builder.PutM m Unit.Unit"
360361 , "put" <> tname <> " (" <> tname <> " r) = do"
361362 , String.joinWith "\n" $ Array.catMaybes
362363 $ (map (genFieldPut nameSpace) field)
363364 <> (Array.mapWithIndex (genOneofPut (nameSpace <> [msgName]) field) oneof_decl)
364365 , " Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields"
365366 , ""
366− , "parse" <> tname <> " :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m " <> tname
367+ , "parse" <> tname <> " :: forall m. MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m " <> tname
367368 , "parse" <> tname <> " length = Runtime.label \"" <> msgName <> " / \" $"
368369 , " Runtime.parseMessage " <> tname <> " default" <> tname <> " parseField length"
369370 , " where"
src/ProtocPlugin/descriptor.Google.Protobuf.purs+28−27
@@ -69,6 +69,7 @@ import Protobuf.Common as Common
6969import Protobuf.Decode as Decode
7070import Protobuf.Encode as Encode
7171import Protobuf.Runtime as Runtime
72+import Control.Monad.Rec.Class (class MonadRec)
7273
7374
7475
@@ -89,7 +90,7 @@ putFileDescriptorSet (FileDescriptorSet r) = do
8990 Runtime.putRepeated 1 r.file $ Runtime.putLenDel putFileDescriptorProto
9091 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
9192
92−parseFileDescriptorSet :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m FileDescriptorSet
93+parseFileDescriptorSet :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m FileDescriptorSet
9394parseFileDescriptorSet length = Runtime.label "FileDescriptorSet / " $
9495 Runtime.parseMessage FileDescriptorSet defaultFileDescriptorSet parseField length
9596 where
@@ -150,7 +151,7 @@ putFileDescriptorProto (FileDescriptorProto r) = do
150151 Runtime.putOptional 12 r.syntax Encode.string
151152 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
152153
153−parseFileDescriptorProto :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m FileDescriptorProto
154+parseFileDescriptorProto :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m FileDescriptorProto
154155parseFileDescriptorProto length = Runtime.label "FileDescriptorProto / " $
155156 Runtime.parseMessage FileDescriptorProto defaultFileDescriptorProto parseField length
156157 where
@@ -257,7 +258,7 @@ putDescriptorProto (DescriptorProto r) = do
257258 Runtime.putRepeated 10 r.reserved_name Encode.string
258259 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
259260
260−parseDescriptorProto :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m DescriptorProto
261+parseDescriptorProto :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m DescriptorProto
261262parseDescriptorProto length = Runtime.label "DescriptorProto / " $
262263 Runtime.parseMessage DescriptorProto defaultDescriptorProto parseField length
263264 where
@@ -336,7 +337,7 @@ putDescriptorProto_ExtensionRange (DescriptorProto_ExtensionRange r) = do
336337 Runtime.putOptional 3 r.options $ Runtime.putLenDel putExtensionRangeOptions
337338 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
338339
339−parseDescriptorProto_ExtensionRange :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m DescriptorProto_ExtensionRange
340+parseDescriptorProto_ExtensionRange :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m DescriptorProto_ExtensionRange
340341parseDescriptorProto_ExtensionRange length = Runtime.label "ExtensionRange / " $
341342 Runtime.parseMessage DescriptorProto_ExtensionRange defaultDescriptorProto_ExtensionRange parseField length
342343 where
@@ -385,7 +386,7 @@ putDescriptorProto_ReservedRange (DescriptorProto_ReservedRange r) = do
385386 Runtime.putOptional 2 r.end Encode.int32
386387 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
387388
388−parseDescriptorProto_ReservedRange :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m DescriptorProto_ReservedRange
389+parseDescriptorProto_ReservedRange :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m DescriptorProto_ReservedRange
389390parseDescriptorProto_ReservedRange length = Runtime.label "ReservedRange / " $
390391 Runtime.parseMessage DescriptorProto_ReservedRange defaultDescriptorProto_ReservedRange parseField length
391392 where
@@ -428,7 +429,7 @@ putExtensionRangeOptions (ExtensionRangeOptions r) = do
428429 Runtime.putRepeated 999 r.uninterpreted_option $ Runtime.putLenDel putUninterpretedOption
429430 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
430431
431−parseExtensionRangeOptions :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m ExtensionRangeOptions
432+parseExtensionRangeOptions :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m ExtensionRangeOptions
432433parseExtensionRangeOptions length = Runtime.label "ExtensionRangeOptions / " $
433434 Runtime.parseMessage ExtensionRangeOptions defaultExtensionRangeOptions parseField length
434435 where
@@ -485,7 +486,7 @@ putFieldDescriptorProto (FieldDescriptorProto r) = do
485486 Runtime.putOptional 8 r.options $ Runtime.putLenDel putFieldOptions
486487 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
487488
488−parseFieldDescriptorProto :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m FieldDescriptorProto
489+parseFieldDescriptorProto :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m FieldDescriptorProto
489490parseFieldDescriptorProto length = Runtime.label "FieldDescriptorProto / " $
490491 Runtime.parseMessage FieldDescriptorProto defaultFieldDescriptorProto parseField length
491492 where
@@ -562,7 +563,7 @@ putOneofDescriptorProto (OneofDescriptorProto r) = do
562563 Runtime.putOptional 2 r.options $ Runtime.putLenDel putOneofOptions
563564 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
564565
565−parseOneofDescriptorProto :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m OneofDescriptorProto
566+parseOneofDescriptorProto :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m OneofDescriptorProto
566567parseOneofDescriptorProto length = Runtime.label "OneofDescriptorProto / " $
567568 Runtime.parseMessage OneofDescriptorProto defaultOneofDescriptorProto parseField length
568569 where
@@ -613,7 +614,7 @@ putEnumDescriptorProto (EnumDescriptorProto r) = do
613614 Runtime.putRepeated 5 r.reserved_name Encode.string
614615 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
615616
616−parseEnumDescriptorProto :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m EnumDescriptorProto
617+parseEnumDescriptorProto :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m EnumDescriptorProto
617618parseEnumDescriptorProto length = Runtime.label "EnumDescriptorProto / " $
618619 Runtime.parseMessage EnumDescriptorProto defaultEnumDescriptorProto parseField length
619620 where
@@ -670,7 +671,7 @@ putEnumDescriptorProto_EnumReservedRange (EnumDescriptorProto_EnumReservedRange
670671 Runtime.putOptional 2 r.end Encode.int32
671672 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
672673
673−parseEnumDescriptorProto_EnumReservedRange :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m EnumDescriptorProto_EnumReservedRange
674+parseEnumDescriptorProto_EnumReservedRange :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m EnumDescriptorProto_EnumReservedRange
674675parseEnumDescriptorProto_EnumReservedRange length = Runtime.label "EnumReservedRange / " $
675676 Runtime.parseMessage EnumDescriptorProto_EnumReservedRange defaultEnumDescriptorProto_EnumReservedRange parseField length
676677 where
@@ -717,7 +718,7 @@ putEnumValueDescriptorProto (EnumValueDescriptorProto r) = do
717718 Runtime.putOptional 3 r.options $ Runtime.putLenDel putEnumValueOptions
718719 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
719720
720−parseEnumValueDescriptorProto :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m EnumValueDescriptorProto
721+parseEnumValueDescriptorProto :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m EnumValueDescriptorProto
721722parseEnumValueDescriptorProto length = Runtime.label "EnumValueDescriptorProto / " $
722723 Runtime.parseMessage EnumValueDescriptorProto defaultEnumValueDescriptorProto parseField length
723724 where
@@ -768,7 +769,7 @@ putServiceDescriptorProto (ServiceDescriptorProto r) = do
768769 Runtime.putOptional 3 r.options $ Runtime.putLenDel putServiceOptions
769770 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
770771
771−parseServiceDescriptorProto :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m ServiceDescriptorProto
772+parseServiceDescriptorProto :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m ServiceDescriptorProto
772773parseServiceDescriptorProto length = Runtime.label "ServiceDescriptorProto / " $
773774 Runtime.parseMessage ServiceDescriptorProto defaultServiceDescriptorProto parseField length
774775 where
@@ -825,7 +826,7 @@ putMethodDescriptorProto (MethodDescriptorProto r) = do
825826 Runtime.putOptional 6 r.server_streaming Encode.bool
826827 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
827828
828−parseMethodDescriptorProto :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m MethodDescriptorProto
829+parseMethodDescriptorProto :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m MethodDescriptorProto
829830parseMethodDescriptorProto length = Runtime.label "MethodDescriptorProto / " $
830831 Runtime.parseMessage MethodDescriptorProto defaultMethodDescriptorProto parseField length
831832 where
@@ -924,7 +925,7 @@ putFileOptions (FileOptions r) = do
924925 Runtime.putRepeated 999 r.uninterpreted_option $ Runtime.putLenDel putUninterpretedOption
925926 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
926927
927−parseFileOptions :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m FileOptions
928+parseFileOptions :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m FileOptions
928929parseFileOptions length = Runtime.label "FileOptions / " $
929930 Runtime.parseMessage FileOptions defaultFileOptions parseField length
930931 where
@@ -1051,7 +1052,7 @@ putMessageOptions (MessageOptions r) = do
10511052 Runtime.putRepeated 999 r.uninterpreted_option $ Runtime.putLenDel putUninterpretedOption
10521053 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
10531054
1054−parseMessageOptions :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m MessageOptions
1055+parseMessageOptions :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m MessageOptions
10551056parseMessageOptions length = Runtime.label "MessageOptions / " $
10561057 Runtime.parseMessage MessageOptions defaultMessageOptions parseField length
10571058 where
@@ -1118,7 +1119,7 @@ putFieldOptions (FieldOptions r) = do
11181119 Runtime.putRepeated 999 r.uninterpreted_option $ Runtime.putLenDel putUninterpretedOption
11191120 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
11201121
1121−parseFieldOptions :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m FieldOptions
1122+parseFieldOptions :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m FieldOptions
11221123parseFieldOptions length = Runtime.label "FieldOptions / " $
11231124 Runtime.parseMessage FieldOptions defaultFieldOptions parseField length
11241125 where
@@ -1181,7 +1182,7 @@ putOneofOptions (OneofOptions r) = do
11811182 Runtime.putRepeated 999 r.uninterpreted_option $ Runtime.putLenDel putUninterpretedOption
11821183 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
11831184
1184−parseOneofOptions :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m OneofOptions
1185+parseOneofOptions :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m OneofOptions
11851186parseOneofOptions length = Runtime.label "OneofOptions / " $
11861187 Runtime.parseMessage OneofOptions defaultOneofOptions parseField length
11871188 where
@@ -1224,7 +1225,7 @@ putEnumOptions (EnumOptions r) = do
12241225 Runtime.putRepeated 999 r.uninterpreted_option $ Runtime.putLenDel putUninterpretedOption
12251226 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
12261227
1227−parseEnumOptions :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m EnumOptions
1228+parseEnumOptions :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m EnumOptions
12281229parseEnumOptions length = Runtime.label "EnumOptions / " $
12291230 Runtime.parseMessage EnumOptions defaultEnumOptions parseField length
12301231 where
@@ -1273,7 +1274,7 @@ putEnumValueOptions (EnumValueOptions r) = do
12731274 Runtime.putRepeated 999 r.uninterpreted_option $ Runtime.putLenDel putUninterpretedOption
12741275 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
12751276
1276−parseEnumValueOptions :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m EnumValueOptions
1277+parseEnumValueOptions :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m EnumValueOptions
12771278parseEnumValueOptions length = Runtime.label "EnumValueOptions / " $
12781279 Runtime.parseMessage EnumValueOptions defaultEnumValueOptions parseField length
12791280 where
@@ -1318,7 +1319,7 @@ putServiceOptions (ServiceOptions r) = do
13181319 Runtime.putRepeated 999 r.uninterpreted_option $ Runtime.putLenDel putUninterpretedOption
13191320 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
13201321
1321−parseServiceOptions :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m ServiceOptions
1322+parseServiceOptions :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m ServiceOptions
13221323parseServiceOptions length = Runtime.label "ServiceOptions / " $
13231324 Runtime.parseMessage ServiceOptions defaultServiceOptions parseField length
13241325 where
@@ -1365,7 +1366,7 @@ putMethodOptions (MethodOptions r) = do
13651366 Runtime.putRepeated 999 r.uninterpreted_option $ Runtime.putLenDel putUninterpretedOption
13661367 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
13671368
1368−parseMethodOptions :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m MethodOptions
1369+parseMethodOptions :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m MethodOptions
13691370parseMethodOptions length = Runtime.label "MethodOptions / " $
13701371 Runtime.parseMessage MethodOptions defaultMethodOptions parseField length
13711372 where
@@ -1424,7 +1425,7 @@ putUninterpretedOption (UninterpretedOption r) = do
14241425 Runtime.putOptional 8 r.aggregate_value Encode.string
14251426 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
14261427
1427−parseUninterpretedOption :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m UninterpretedOption
1428+parseUninterpretedOption :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m UninterpretedOption
14281429parseUninterpretedOption length = Runtime.label "UninterpretedOption / " $
14291430 Runtime.parseMessage UninterpretedOption defaultUninterpretedOption parseField length
14301431 where
@@ -1489,7 +1490,7 @@ putUninterpretedOption_NamePart (UninterpretedOption_NamePart r) = do
14891490 Runtime.putOptional 2 r.is_extension Encode.bool
14901491 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
14911492
1492−parseUninterpretedOption_NamePart :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m UninterpretedOption_NamePart
1493+parseUninterpretedOption_NamePart :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m UninterpretedOption_NamePart
14931494parseUninterpretedOption_NamePart length = Runtime.label "NamePart / " $
14941495 Runtime.parseMessage UninterpretedOption_NamePart defaultUninterpretedOption_NamePart parseField length
14951496 where
@@ -1532,7 +1533,7 @@ putSourceCodeInfo (SourceCodeInfo r) = do
15321533 Runtime.putRepeated 1 r.location $ Runtime.putLenDel putSourceCodeInfo_Location
15331534 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
15341535
1535−parseSourceCodeInfo :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m SourceCodeInfo
1536+parseSourceCodeInfo :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m SourceCodeInfo
15361537parseSourceCodeInfo length = Runtime.label "SourceCodeInfo / " $
15371538 Runtime.parseMessage SourceCodeInfo defaultSourceCodeInfo parseField length
15381539 where
@@ -1579,7 +1580,7 @@ putSourceCodeInfo_Location (SourceCodeInfo_Location r) = do
15791580 Runtime.putRepeated 6 r.leading_detached_comments Encode.string
15801581 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
15811582
1582−parseSourceCodeInfo_Location :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m SourceCodeInfo_Location
1583+parseSourceCodeInfo_Location :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m SourceCodeInfo_Location
15831584parseSourceCodeInfo_Location length = Runtime.label "Location / " $
15841585 Runtime.parseMessage SourceCodeInfo_Location defaultSourceCodeInfo_Location parseField length
15851586 where
@@ -1640,7 +1641,7 @@ putGeneratedCodeInfo (GeneratedCodeInfo r) = do
16401641 Runtime.putRepeated 1 r.annotation $ Runtime.putLenDel putGeneratedCodeInfo_Annotation
16411642 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
16421643
1643−parseGeneratedCodeInfo :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m GeneratedCodeInfo
1644+parseGeneratedCodeInfo :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m GeneratedCodeInfo
16441645parseGeneratedCodeInfo length = Runtime.label "GeneratedCodeInfo / " $
16451646 Runtime.parseMessage GeneratedCodeInfo defaultGeneratedCodeInfo parseField length
16461647 where
@@ -1685,7 +1686,7 @@ putGeneratedCodeInfo_Annotation (GeneratedCodeInfo_Annotation r) = do
16851686 Runtime.putOptional 4 r.end Encode.int32
16861687 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
16871688
1688−parseGeneratedCodeInfo_Annotation :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m GeneratedCodeInfo_Annotation
1689+parseGeneratedCodeInfo_Annotation :: forall m. Effect.MonadEffect m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m GeneratedCodeInfo_Annotation
16891690parseGeneratedCodeInfo_Annotation length = Runtime.label "Annotation / " $
16901691 Runtime.parseMessage GeneratedCodeInfo_Annotation defaultGeneratedCodeInfo_Annotation parseField length
16911692 where
src/ProtocPlugin/plugin.Google.Protobuf.Compiler.purs+5−4
@@ -40,6 +40,7 @@ import Protobuf.Common as Common
4040import Protobuf.Decode as Decode
4141import Protobuf.Encode as Encode
4242import Protobuf.Runtime as Runtime
43+import Control.Monad.Rec.Class (class MonadRec)
4344
4445import Google.Protobuf.Descriptor as Google.Protobuf
4546
@@ -67,7 +68,7 @@ putVersion (Version r) = do
6768 Runtime.putOptional 4 r.suffix Encode.string
6869 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
6970
70−parseVersion :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m Version
71+parseVersion :: forall m. Effect.MonadEffect m => MonadRec m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m Version
7172parseVersion length = Runtime.label "Version / " $
7273 Runtime.parseMessage Version defaultVersion parseField length
7374 where
@@ -124,7 +125,7 @@ putCodeGeneratorRequest (CodeGeneratorRequest r) = do
124125 Runtime.putOptional 3 r.compiler_version $ Runtime.putLenDel putVersion
125126 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
126127
127−parseCodeGeneratorRequest :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m CodeGeneratorRequest
128+parseCodeGeneratorRequest :: forall m. Effect.MonadEffect m => MonadRec m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m CodeGeneratorRequest
128129parseCodeGeneratorRequest length = Runtime.label "CodeGeneratorRequest / " $
129130 Runtime.parseMessage CodeGeneratorRequest defaultCodeGeneratorRequest parseField length
130131 where
@@ -177,7 +178,7 @@ putCodeGeneratorResponse (CodeGeneratorResponse r) = do
177178 Runtime.putRepeated 15 r.file $ Runtime.putLenDel putCodeGeneratorResponse_File
178179 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
179180
180−parseCodeGeneratorResponse :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m CodeGeneratorResponse
181+parseCodeGeneratorResponse :: forall m. Effect.MonadEffect m => MonadRec m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m CodeGeneratorResponse
181182parseCodeGeneratorResponse length = Runtime.label "CodeGeneratorResponse / " $
182183 Runtime.parseMessage CodeGeneratorResponse defaultCodeGeneratorResponse parseField length
183184 where
@@ -224,7 +225,7 @@ putCodeGeneratorResponse_File (CodeGeneratorResponse_File r) = do
224225 Runtime.putOptional 15 r.content Encode.string
225226 Traversable.traverse_ Runtime.putFieldUnknown r.__unknown_fields
226227
227−parseCodeGeneratorResponse_File :: forall m. Effect.MonadEffect m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m CodeGeneratorResponse_File
228+parseCodeGeneratorResponse_File :: forall m. Effect.MonadEffect m => MonadRec m => MonadRec m => Int -> Parser.ParserT ArrayBuffer.Types.DataView m CodeGeneratorResponse_File
228229parseCodeGeneratorResponse_File length = Runtime.label "File / " $
229230 Runtime.parseMessage CodeGeneratorResponse_File defaultCodeGeneratorResponse_File parseField length
230231 where