From 0dcef38a276c1ea656025c6ea5bb855c9a8a5df1 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, 4 insertions(+), 9 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..0fc87496 100644 --- a/lambda-buffers-codegen/src/LambdaBuffers/Codegen/LamVal/Json.hs +++ b/lambda-buffers-codegen/src/LambdaBuffers/Codegen/LamVal/Json.hs @@ -264,15 +264,10 @@ fromJsonProduct ty qprod@(qtyN, prodTy) = 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 - ] + ( \recVal -> 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 `.