From 2954fd9c732a0d7e92c1cec0e26ddf15e4207ffb Mon Sep 17 00:00:00 2001 From: jared <> Date: Tue, 9 Apr 2024 01:12:18 -0600 Subject: [PATCH] Allow empty records for JSON generation --- .../src/LambdaBuffers/Codegen/LamVal/Json.hs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lambda-buffers-codegen/src/LambdaBuffers/Codegen/LamVal/Json.hs b/lambda-buffers-codegen/src/LambdaBuffers/Codegen/LamVal/Json.hs index dbcdb2bf..9744def9 100644 --- a/lambda-buffers-codegen/src/LambdaBuffers/Codegen/LamVal/Json.hs +++ b/lambda-buffers-codegen/src/LambdaBuffers/Codegen/LamVal/Json.hs @@ -265,14 +265,11 @@ toJsonRecord :: QRecord -> ValueE toJsonRecord (qtyN, recTy) = LamE ( \recVal -> - case OMap.assocs recTy of - [] -> ErrorE "Got an empty Record type to print in `toJsonRecord`" - _ -> - jsonObjRef - @ ListE - [ TupleE (fieldNameVal fieldName) (toJsonRef fieldTy @ FieldE (qtyN, fieldName) recVal) - | (fieldName, fieldTy) <- sortOn fst $ OMap.assocs recTy - ] + jsonObjRef + @ ListE + [ TupleE (fieldNameVal fieldName) (toJsonRef fieldTy @ FieldE (qtyN, fieldName) recVal) + | (fieldName, fieldTy) <- sortOn fst $ OMap.assocs recTy + ] ) {- | `fromJsonRecord ty qrec` makes a `LamVal` function for decoding record type values from their JSON representation `fromJson :: Json -> Parser `.