Status: Started
Owner: [email protected]
CC: [email protected], [email protected]
Labels: Type-Defect Priority-Medium Milestone-Release2.11 Maintainability
HaskellTask
New issue 677 by [email protected]: It's not possible to create fields
(THH) that have both custom fieldRead/Show and fieldDefault
http://code.google.com/p/ganeti/issues/detail?id=677
What steps will reproduce the problem?
Create a field with custom fieldRead and fieldDefault.
What is the expected output? What do you see instead?
I'd expect the generated expression to compile. Instead, the compilation
fails with typing errors.
Please use labels and text to provide additional information.
The problem is that with custom fieldRead, the JSON data are parsed twice.
Once when being extracted from a JSON object and then in the custom
function. The generated code looks like this:
(fromObj o "fieldname" >>= customFieldRead o)
It works, I'd say by accident, because the result type of `fromObj` is
specialized to `JSValue`. But with a default field, we get (let's say the
default value is `0 :: Int`)
(fromObjWithDefault o "fieldname" 0 >>= customFieldRead o)
which fails, because now we're feeding `Int` to the custom field reader.
Currently it's possible to work around this problem by giving the default
field value as an expression of type `JSValue`, but this is a hack.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings