haskell/aeson

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

quintenkasteel opened this issue · 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.

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

Please provide a complete reproducer.

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.