
I'm using Haskell to build a web services client. The API uses JSON, so I've been playing around with Text.JSON. Text.JSON works, but it seems kind of clumsy to me. I suspect that it's my failure to understand the proper usage pattern, rather than an issue with the design. For much of what I'm doing, I don't know *exactly* what I'm going to get back. I know that there will be specific JSON fields I'm interested in, but there may be ones I'm not expecting. Writing a readJSON for a pre-designed data structure is not the right answer. I'm not marshalling and un-marshalling structures that originate in Haskell. The structures I am un-marshalling are subject to extension. it seems like the default invocation of decode is something like: (decode aString) :: Result JSValue Is that correct? I'm unclear on the design goals of parameterizing JSObject. Why isn't JSObject just a list of (String,JSValue) tuples? What do we get from parameterizing it? What's the intent of having JSObject as a data constructor for JSValue and as a distinct type constructor (whose hidden data constructor is JSONObject)? What do we get from this? Why hide JSONObject? The way things are constructed, we always end up with two layers of data constructors for JSON objects JSObject (JSONObject ...). What do we get from this additional complexity. -r hayes

I'm unclear on the design goals of parameterizing JSObject. Why isn't JSObject just a list of (String,JSValue) tuples?
Doing things this way permits the avoidance of the OverlappingInstances extension, and so makes the library H98 compliant. The downside is that the library is really clunky to use.

bos:
I'm unclear on the design goals of parameterizing JSObject. Why isn't JSObject just a list of (String,JSValue) tuples?
Doing things this way permits the avoidance of the OverlappingInstances extension, and so makes the library H98 compliant. The downside is that the library is really clunky to use.
If its *really* clunky, we can provide the overlapping interface as well... How strongly to people feel? -- Don

I'm unclear on the design goals of parameterizing JSObject. Why isn't JSObject just a list of (String,JSValue) tuples? What do we get from parameterizing it?
Not to be pedantic, but if you want to represent the JSObject as a simple datatype like this, it should probably be a Map String JSValue, not a list, since JSON objects are inherently unordered.
participants (4)
-
Andrew Wagner
-
Bryan O'Sullivan
-
Don Stewart
-
R Hayes