mirror of
https://github.com/github/semantic.git
synced 2024-12-22 06:11:49 +03:00
Pass the original field number into the generate function
This commit is contained in:
parent
1a49b3e197
commit
2063798b24
@ -107,10 +107,10 @@ infixContext context left right operators = uncurry (&) <$> postContextualizeThr
|
|||||||
instance (Apply Message1 fs, Generate Message1 fs fs, Generate Named1 fs fs) => Message1 (Sum fs) where
|
instance (Apply Message1 fs, Generate Message1 fs fs, Generate Named1 fs fs) => Message1 (Sum fs) where
|
||||||
liftEncodeMessage encodeMessage num fs = Encode.embedded (FieldNumber . fromIntegral . succ $ elemIndex fs) message
|
liftEncodeMessage encodeMessage num fs = Encode.embedded (FieldNumber . fromIntegral . succ $ elemIndex fs) message
|
||||||
where message = apply @Message1 (liftEncodeMessage encodeMessage num) fs
|
where message = apply @Message1 (liftEncodeMessage encodeMessage num) fs
|
||||||
liftDecodeMessage decodeMessage _ = Decode.oneof undefined listOfParsers
|
liftDecodeMessage decodeMessage num' = Decode.oneof undefined listOfParsers
|
||||||
where
|
where
|
||||||
listOfParsers =
|
listOfParsers =
|
||||||
generate @Message1 @fs @fs (\ (_ :: proxy f) i -> let num = FieldNumber (fromInteger (succ i)) in [(num, fromJust <$> Decode.embedded (inject @f @fs <$> liftDecodeMessage decodeMessage num))])
|
generate @Message1 @fs @fs (\ (_ :: proxy f) i -> let num = fromInteger (succ i) in [(num, fromJust <$> Decode.embedded (inject @f @fs <$> liftDecodeMessage decodeMessage num'))])
|
||||||
liftDotProto _ =
|
liftDotProto _ =
|
||||||
[Proto.DotProtoMessageOneOf (Proto.Single "syntax") (generate @Named1 @fs @fs (\ (_ :: proxy f) i ->
|
[Proto.DotProtoMessageOneOf (Proto.Single "syntax") (generate @Named1 @fs @fs (\ (_ :: proxy f) i ->
|
||||||
let
|
let
|
||||||
|
Loading…
Reference in New Issue
Block a user