[Haskell-cafe] Bytestring map/zipWith rationale

John Lato jwlato at gmail.com
Thu Sep 12 20:10:57 CEST 2013


Carter: we don't have both.  We have one function from each category.  My
guess is nobody's ever really needed a really fast zipWith ::
(Word8->Word8->Word8) -> ByteString -> ByteString -> ByteString; that's the
only reason I can think of for its omission.


On Thu, Sep 12, 2013 at 10:45 AM, Carter Schonwald <
carter.schonwald at gmail.com> wrote:

> Scott: benchmark the two and you'll see why we have both :-)
>
>
> On Thursday, September 12, 2013, Scott Lawrence wrote:
>
>> On Thu, 12 Sep 2013, Tom Ellis wrote:
>>
>>  On Thu, Sep 12, 2013 at 09:21:20AM -0400, Scott Lawrence wrote:
>>>
>>>> Something's always bothered me about map and zipWith for ByteString.
>>>> Why is it
>>>>
>>>>     map :: (Word8 -> Word8) -> ByteString -> ByteString
>>>>
>>>> but
>>>>
>>>>     zipWith :: (Word8 -> Word8 -> a) -> ByteString -> ByteString -> [a]
>>>>
>>>
>>> Well, what if you wanted to zipWith a function of type "Word8 -> Word8 ->
>>> Foo" instead of "Word8 -> Word8 -> Word8"?
>>>
>>
>> Then I would do what I do with map, and call `unpack` first.
>>
>> Either of the two options is usable:
>>
>>  map :: (Word8 -> Word8) -> ByteString -> ByteString
>>  zipWith :: (Word8 -> Word8 -> Word8) -> ByteString -> ByteString ->
>> ByteString
>>    (or)
>>  map :: (Word8 -> a) -> ByteString -> [a]
>>  zipWith :: (Word8 -> Word8 -> a) -> ByteString -> ByteString -> [a]
>>
>> I just don't understand why we have one from each.
>>
>> --
>> Scott Lawrence
>> ______________________________**_________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/**mailman/listinfo/haskell-cafe<http://www.haskell.org/mailman/listinfo/haskell-cafe>
>>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130912/98ded798/attachment.htm>


More information about the Haskell-Cafe mailing list