[racket] Typed Racket - Structure Procedures

From: Ray Racine (ray.racine at gmail.com)
Date: Sun May 29 03:26:00 EDT 2011

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.

I'd like to get the commented out sections to work as well.  Thanks in

#lang typed/racket

(define-type Fn1 (All (a b) a -> b))

(struct: (a b) PartialFn ([fn : (Fn1 a b)] [defined-at? : (a -> Boolean)])
 #:property prop:procedure (struct-field-index fn))

;; (: defined-at? (All (a b) (PartialFn a b) a -> Boolean))
;; (define (defined-at? pf value)
;;   ((PartialFn-defined-at? pf) value))

(: f (Integer -> String))
(define f (lambda: ((x : Integer)) "Hello"))

(: f-range (Integer -> Boolean))
(define (f-range x)
  (and (> x 0) (< x 10)))

(: pf (PartialFn Integer String))
(define pf (PartialFn f f-range))

((PartialFn-defined-at? pf) 3)
((PartialFn-fn pf) 3) ;; works

;; (pf 3) ;; -> Hello
;; (defined-at? pf 3) ;; -> #t
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110529/0d0e0e37/attachment.html>

Posted on the users mailing list.