<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Types are a purely compile-time construct, so type polymorphism doesn’t make any sense in a dynamic context. You can create a predicate that checks if some value is any Foo:</div><div class=""><br class=""></div><div class=""><font face="Courier" class="">(define-predicate foo? (Foo Any))</font></div><div class=""><br class=""></div><div class="">Or you can even create a predicate that checks if some value is a specific type of Foo:</div><div class=""><br class=""></div><div class=""><font face="Courier" class="">(define-syntax-rule (Foo? A)</font></div><div class=""><font face="Courier" class=""> (make-predicate (Foo A))</font></div><div class=""><br class=""></div><div class="">But in the latter case, the type obviously must be known at compile-time.</div><div class=""><br class=""></div><div class="">As Alexander mentions, the snapshot version of Typed Racket exports typed/json, but it just uses <font face="Courier" class="">'null</font> for all null values, mostly to sidestep this problem, and because custom nulls are relatively pointless, anyway.</div><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 17, 2015, at 18:20, Jordan Johnson <<a href="mailto:jmj@fellowhuman.com" class="">jmj@fellowhuman.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">Hi all,<br class=""><br class="">In playing with TR this evening, I found<br class=""><br class=""><blockquote type="cite" class="">(define-type (Foo A)<br class=""> (U A<br class=""> (List 'foo (Foo A))))<br class=""><br class="">(define-predicate foo? Foo)<br class=""></blockquote><br class="">generates the error “Type Foo could not be converted to a contract: cannot generate contract for non-function polymorphic type”. I’ve read the page with caveats about inference and polymorphic types, but since the example is about using a function rather than defining a predicate, I’m not clear on how (if at all) the technique could be adapted for this.<br class=""><br class="">(What I was actually doing, by the way, was seeing if I could port the JSON library to TR. I ran into the problem of the null element being of arbitrary type.)<br class=""><br class="">Best,<br class="">jmj<br class=""><br class=""><br class="">____________________<br class=""> Racket Users list:<br class=""> <a href="http://lists.racket-lang.org/users" class="">http://lists.racket-lang.org/users</a><br class=""></div></blockquote></div><br class=""></body></html>