<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Dec 5, 2014, at 11:30 PM, Alexis King <<a href="mailto:lexi.lambda@gmail.com">lexi.lambda@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=utf-8"><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I’ve been having an issue figuring out how to properly use the json library in typed racket, so I posted <a href="http://stackoverflow.com/q/27304901/465378" class="">a question</a> about it on SO. Any help would be greatly appreciated!</div>____________________<br>  Racket Users list:<br>  <a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br></blockquote></div><br><div><blockquote type="cite"><span style="font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 18px; background-color: rgb(255, 255, 255);">The trouble is that a </span><code style="margin: 0px; padding: 1px 5px; border: 0px; font-size: 14px; vertical-align: baseline; background-color: rgb(238, 238, 238); font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: pre-wrap; line-height: 18px;">jsexpr</code><span style="font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 18px; background-color: rgb(255, 255, 255);"> is </span><em style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; background-color: rgb(255, 255, 255); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px;">not</em><span style="font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 18px; background-color: rgb(255, 255, 255);"> a struct, </span><code style="margin: 0px; padding: 1px 5px; border: 0px; font-size: 14px; vertical-align: baseline; background-color: rgb(238, 238, 238); font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: pre-wrap; line-height: 18px;">jsexpr?</code><span style="font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 18px; background-color: rgb(255, 255, 255);"> is simply a predicate that tests whether or not a given value fits a certain structure. </span></blockquote></div><div><br></div><div>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.</div><div><br></div><div><div>To the rest of the list:</div></div><div><br></div><div><div></div><blockquote type="cite"><div>(require/typed json</div><div>               [jsexpr? (-> Any Boolean : JSExpr)])</div><br class="Apple-interchange-newline">Unfortunately, this doesn't work, either, because filters can't be used in require/typed.</blockquote></div><div><br></div><div>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 ?</div><div>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?</div><div><div>(require/typed 2htdp/universe</div><div>               [key-event? (Any -> Boolean : #:+ String)])</div></div><div><br></div></body></html>