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

From: Alexander D. Knauth (alexander at knauth.org)
Date: Sat Dec 6 00:37:53 EST 2014

On Dec 5, 2014, at 11:30 PM, Alexis King <lexi.lambda at gmail.com> wrote:

> I’ve been having an issue figuring out how to properly use the json library in typed racket, so I posted a question about it on SO. Any help would be greatly appreciated!
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

> The trouble is that a jsexpr is not a struct, jsexpr? is simply a predicate that tests whether or not a given value fits a certain structure. 


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.

To the rest of the list:

> (require/typed json
>                [jsexpr? (-> Any Boolean : JSExpr)])
> 
> Unfortunately, this doesn't work, either, because filters can't be used in require/typed.


Is there any particular reason why there can’t be filters in require/typed for types where there can be a predicate created by make-predicate ?
It still wouldn’t work for JSExpr because it can’t define a predicate, but is there any reason why something like this couldn’t work?
(require/typed 2htdp/universe
               [key-event? (Any -> Boolean : #:+ String)])

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20141206/47bc226e/attachment.html>

Posted on the users mailing list.