[racket] problem (?) with typed racket
On Jul 5, 2010, at 10:09 AM, Jose A. Ortega Ruiz wrote:
>
> (: carrow (All (E) (C (Arrow E))))
> (define carrow
> (C #{compose-arrows :: ((Arrow E) (Arrow E) -> (Arrow E))}))
That one stumps me too. Here is what works:
#lang typed/racket
(define-struct: (E) Arrow ([arrow : (E -> (Listof E))]))
(: compose-arrows (All (E) ((Arrow E) (Arrow E) -> (Arrow E))))
(define (compose-arrows a b)
(Arrow (lambda: ((e : E)) ((Arrow-arrow a) (car ((Arrow-arrow b) e))))))
(define-struct: (A) C ([compose : (A A -> A)]))
(: carrow (All (E) (Any -> (C (Arrow E)))))
(define (carrow a)
(C (inst compose-arrows E)))
(define c (carrow 0))
I am beginning to wonder whether this is a scoping bug. E should be available in the scope of your carrow.
-- Matthias