[racket] Constructors for sequences

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Sun Apr 29 12:49:25 EDT 2012

On Sun, Apr 29, 2012 at 12:43 PM, Matthias Felleisen
<matthias at ccs.neu.edu> wrote:
>
> What you're really saying is that sequence-map uses the wrong kind of type. Specifically, it should be polymorphic in the sequence constructor instead of mapping everything to the top of the class hierarchy (sequence).
>
> Interesting point is that you described/found this problem in a type-free world.
>
> Question is how we should deal with this in Typed Racket, given our lack of bounded polymorphism

The Scala collections classes go to a *lot* of work to make this all
work nicely in a typed setting.  But it's way more than just bounded
polymorphism that they use.

>
> -- Matthias
>
>
>
>
> On Apr 29, 2012, at 8:12 AM, Jens Axel Søgaard wrote:
>
>> Given a sequence is there way to get the "constructor" of the sequence?
>>
>> (sequence-constructor (list 1 2 3))  = list
>> (sequence-constructor (vector 1 2 3))  = vector
>> etc
>>
>> I'd like to use it for a declare-mappable macro that extends functions
>> of one argument
>> to map over sequences. As in (sin (list 1 2 3)) = (list (sin 1) (sin
>> 2) (sin 3)).
>>
>> The sequence-map function is close, but it produces sequences.
>> Now I could of course hard code the usual suspects, but it seems
>> somewhat inelegant.
>>
>> --
>> Jens Axel Søgaard
>>
>> ____________________
>>  Racket Users list:
>>  http://lists.racket-lang.org/users
>
>
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.