aeson icon indicating copy to clipboard operation
aeson copied to clipboard

Parse exception raised for combination of .: and .!=

Open quintenkasteel opened this issue 1 year ago • 2 comments

We use aeson-1.4.7.1.

The following code raises an exception:

for the type: data = Field {field :: Text} field .: "fieldName" .!= "" raises an exception.

It would be great if this could raise an compile error instead.

quintenkasteel avatar Jul 05 '24 09:07 quintenkasteel

I don't understand. What you mean by raises an exception?

Please provide a complete reproducer.

phadej avatar Jul 05 '24 11:07 phadej

If i have a JSON record that looks like the following: { "fieldName": null }

If i use the parser: field .: "fieldName" .!= "" it will compile. But it will always raise an JSONConversionException: "key "fieldName" not found"

I would like to get an compile error, as this code is not valid. The parser should use the parser for Maybe values: field .:? "fieldName" .!= ""

I can code a minimal example if you need more clarification.

quintenkasteel avatar Jul 05 '24 14:07 quintenkasteel