[racket] problem (?) with typed racket

From: Jose A. Ortega Ruiz (jao at gnu.org)
Date: Mon Jul 5 11:39:21 EDT 2010

On Mon, Jul 05 2010, Matthias Felleisen wrote:

> 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))

Yes. Defining `carrow' as a procedure taking no arguments works for me
too; that and, specially, using `inst' instead of my clunky #{...}
annotation makes things much more elegant.

As i understand it better, i'm liking typed racket more and more. My
kudos to Matthias, Sam and anyone else involved.

Thanks again,
jao
-- 
Children enter school as question marks and leave as periods.
 -Neil Postman, professor and author (1931-2003)



Posted on the users mailing list.