[racket-dev] more general typed/scheme bafflement...

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Tue Jun 7 19:26:17 EDT 2011

John,

You had an easy time with + because it is monomorphic.  You are having
trouble applying one polymorphic function (map) to another (list or
list2).  Instantiate one or both functions explicitly, and Typed
Racket won't get confused by the guesswork.

Also, T ... i in a type does not mean T ... followed by i.  It means T
... *indexed* by i.  It's clarifying what the ... ranges over.

Carl Eastlund

On Tue, Jun 7, 2011 at 7:16 PM, John Clements <clements at brinckerhoff.org> wrote:
> I see that map works on multiple lists in at least one circumstance, e.g. (map + (list 3 4) (list 4 5)).  I couldn't get it to work with "list", though, even when I specialized list to a two-argument function:
>
> #lang typed/racket
>
> (: list2 (All (T) (T T -> (List T T))))
> (define (list2 a b) (list a b))
>
> (map list2 '(3 4 5) '(10 11 12))
>
> ==> Type Checker: Polymorphic function map could not be applied to arguments:
> Domains: (a -> c) (Pairof a (Listof a))
>         (a b ... b -> c) (Listof a) (Listof b) ... b
> Arguments: (All (T) (T T -> (List T T))) (List Positive-Byte Positive-Byte Positive-Byte) (List Positive-Byte Positive-Byte Positive-Byte)
>  in: (map list2 (quote (3 4 5)) (quote (10 11 12)))
>
> Is there some easy fix here?
>
> Also, I am deeply confused by the second of those domains, that makes it appear that I'm supposed apply map to a bunch of lists and then to a bare "b".
>
> John
>
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/dev
>



Posted on the dev mailing list.