<div>Just can't say enough how cool typed/racket is. Playing around a bit more with typed/racket and unable to get the below to work, however I'd really like to. :) Tried using define-struct/exec as well but to no avail. </div>
<div><br></div><div>I'd like to get the commented out sections to work as well. Thanks in advance.</div><div><br></div><div><div>#lang typed/racket</div><div><br></div><div>(define-type Fn1 (All (a b) a -> b))</div>
<div><br></div><div>(struct: (a b) PartialFn ([fn : (Fn1 a b)] [defined-at? : (a -> Boolean)])</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> #:property prop:procedure (struct-field-index fn))</div>
<div><br></div><div>;; (: defined-at? (All (a b) (PartialFn a b) a -> Boolean))</div><div>;; (define (defined-at? pf value)</div><div>;; ((PartialFn-defined-at? pf) value))</div><div><br></div><div>(: f (Integer -> String))</div>
<div>(define f (lambda: ((x : Integer)) "Hello"))</div><div><br></div><div>(: f-range (Integer -> Boolean))</div><div>(define (f-range x)</div><div> (and (> x 0) (< x 10)))</div><div><br></div><div>(: pf (PartialFn Integer String))</div>
<div>(define pf (PartialFn f f-range))</div><div><br></div><div>((PartialFn-defined-at? pf) 3)</div><div>((PartialFn-fn pf) 3) ;; works</div><div><br></div><div>;; (pf 3) ;; -> Hello</div><div>;; (defined-at? pf 3) ;; -> #t</div>
<div><br></div></div>