From 2063798b24c65445d094d664d59d888dbc48b71b Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 11 Jun 2018 18:30:13 -0400 Subject: [PATCH] Pass the original field number into the generate function --- src/Data/Syntax.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Data/Syntax.hs b/src/Data/Syntax.hs index 7282d84fc..004cee6e7 100644 --- a/src/Data/Syntax.hs +++ b/src/Data/Syntax.hs @@ -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 liftEncodeMessage encodeMessage num fs = Encode.embedded (FieldNumber . fromIntegral . succ $ elemIndex fs) message where message = apply @Message1 (liftEncodeMessage encodeMessage num) fs - liftDecodeMessage decodeMessage _ = Decode.oneof undefined listOfParsers + liftDecodeMessage decodeMessage num' = Decode.oneof undefined listOfParsers where 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 _ = [Proto.DotProtoMessageOneOf (Proto.Single "syntax") (generate @Named1 @fs @fs (\ (_ :: proxy f) i -> let