[racket] Issue with require/typed and the json library

From: John Clements (johnbclements at gmail.com)
Date: Wed Dec 10 14:56:01 EST 2014

Possibly related: the last time I checked, there was no widely adopted
schema system for JSON, which is completely appalling. That is, it’s not
possible to document an HTTP call as “returning a JSON object with field
“timestamp” which is an integer and “value” which is a string and no other
fields thank you very much” except by writing the english text. My
impression is that in the great XML -> JSON switchover, schemas were the
baby that was thrown out with the bathwater.

John Clements



On Sat, Dec 6, 2014 at 7:37 AM, Matthias Felleisen <matthias at ccs.neu.edu>
wrote:

>
> On Dec 6, 2014, at 1:08 AM, Alexis King wrote:
>
> It doesn’t have to be a struct, but the problem is that typed racket
> doesn’t know that a value of type String for instance will be of type
> JSExpr or not, so you would have to put (assert x jsexpr?) around
> everything that you want to treat as a jsexpr.
>
>
> Ah, that’s interesting. I’d seen assert when digging through the docs, but
> I didn’t quite realize how it worked at the time. Looking back at it again,
> I’m surprised I missed it, but no matter.
>
> That *does* solve the problem, albeit rather inelegantly. I’d be
> interested to see if there’s another way, but I would understand why it
> would be difficult to implement a cleaner approach.
>
>
> From 100,000 ft:
>
>  JSON and XML and such things have one of two types: a coarse one that
> does not really address the things a programmer thinks and an incredibly
> fine-grained one that expresses all of these things. The latter requires a
> highly intrinsic, complicated, difficult to use thing [due to the
> union/recursive/dynamic nature of the objects], which no real languages
> comes with. I conjecture that TR could accommodate just such a type system
> -- but that might be a dissertation. I should talk to Sam.
>
> -- Matthias
>
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20141210/54867696/attachment-0001.html>

Posted on the users mailing list.