[racket] problem with map example in docs of typed/racket

From: Jos Koot (jos.koot at telefonica.net)
Date: Thu Aug 26 15:54:46 EDT 2010

Two things worry me:

In your version,
(my-map list '(1 2 3) '(a b c))
results in an exception.

2:
Replacing the internal calls to map by calls to my-map does not pass
check-syntax.

It may be my ignorance, though. I just started looking into TR.

Jos  

> -----Original Message-----
> From: Hari Prashanth [mailto:krhari at ccs.neu.edu] 
> Sent: 26 August 2010 20:17
> To: Jos Koot
> Cc: PLT-Scheme Mailing List
> Subject: Re: [racket] problem with map example in docs of typed/racket
> 
> I think the example should be changed to
> 
> (: my-map
>    (All (C A B ...)
>         ((A B ... B -> C) (Listof A) (Listof B) ... B -> 
> (Listof C)))) (define (my-map f as . bss)
>   (if (or (null? as) (ormap null? bss))
>       null
>       (cons (apply f (car as) (map car bss))
>             (apply my-map f (cdr as) (map cdr bss)))))
> 
> 
> Hari
> 
> ----- Original Message -----
> From: "Jos Koot" <jos.koot at telefonica.net>
> To: "PLT-Scheme Mailing List" <users at lists.racket-lang.org>
> Sent: Thursday, August 26, 2010 12:51:58 PM GMT -05:00 
> US/Canada Eastern
> Subject: [racket] problem with map example in docs of typed/racket
> 
> 
> 
> See below,
> Jos 
> 
> In definitions window 
> 
> #lang typed/racket
> (: map
> (All (C A B ...)
> ((A B ... B -> C) (Listof A) (Listof B) ... B 
> -> 
> (Listof C))))
> (define (map f as . bss)
> (if (or (null? as)
> (ormap null? bss))
> null
> (cons (apply f (car as) (map car bss)) ; These to lines 
> (apply map f (cdr as) (map cdr bss))))) ; are highlighted 
> 
> Run, then in interactions window: 
> 
> 
> Welcome to DrRacket, version 
> 5.0.1.3--2010-08-19(e55f0cade1d47b2edbc65e7dd61ddce2041814af/a) [3m]. 
> Language: typed/racket. 
> . Type Checker: Polymorphic function map could not be applied 
> to arguments: 
> Domain: (A B ... B -> C) (Listof A) (Listof B) ... B
> Arguments: (All (a b) (case-lambda ((Pairof a b) -> a) 
> ((Listof a) -> a))) (List (Listof B) ... B)
> in: (map car bss)
> . Type Checker: Bad arguments to function in apply: 
> Domain: A B ... B
> Arguments: A Nothing *
> in: (apply f (car as) (map car bss))
> . Type Checker: Polymorphic function map could not be applied 
> to arguments: 
> Domain: (A B ... B -> C) (Listof A) (Listof B) ... B
> Arguments: (All (a b) (case-lambda ((Pairof a b) -> b) 
> ((Listof a) -> (Listof a)))) (List (Listof B) ... B)
> in: (map cdr bss)
> . Type Checker: Bad arguments to polymorphic function in apply: 
> Domain: (A B ... B -> C) (Listof A) (Listof B) ... B
> Arguments: (A B ... B -> C) (Listof A) Nothing *
> in: (apply map f (cdr as) (map cdr bss)) . Type Checker: 
> Summary: 4 errors encountered in: 
> (map car bss)
> (apply f (car as) (map car bss))
> (map cdr bss)
> (apply map f (cdr as) (map cdr bss)) 
> > 
> 
> 
> 
> 
> 
> _________________________________________________
>   For list-related administrative tasks:
>   http://lists.racket-lang.org/listinfo/users




Posted on the users mailing list.