[Haskell-beginners] Abstracting Data.List

mukesh tiwari mukeshtiwari.iiitm at gmail.com
Fri May 31 17:43:02 CEST 2013


Hi Brandon,

On Fri, May 31, 2013 at 8:01 PM, Brandon Allbery <allbery.b at gmail.com>wrote:

> On Fri, May 31, 2013 at 6:16 AM, mukesh tiwari <
> mukeshtiwari.iiitm at gmail.com> wrote:
>
>> Data.List can be abstracted using Foldable and Traversable but
>> unfortunately I could not find the functions corresponding to head, take.
>>
>
> Those are, again, more general than you want. What is the `head` of a
> HashMap? (Consider that an implementation may choose to randomize the hash
> function to avoid hash collision attacks.) Foldable and Traversable express
> the concept of a collection which has no meaningful concept of an element's
> relative position within the collection. ListLike adds the concept of
> position, thereby admitting an indexing operation (and, by extension,
> `head` which is index 0).
>

Thanks for explanation. Precisely a tree was in the mind so there is no
concept of head or take. Data.Foldable.toList could be used to convert the
foldable structure to list but again it's not useful because Giacomo wants
to abstract the List.

-Mukesh


>
> --
> brandon s allbery kf8nh                               sine nomine
> associates
> allbery.b at gmail.com
> ballbery at sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130531/972f4bea/attachment.htm>


More information about the Beginners mailing list