[Haskell-beginners] Haskell laziness and data structures.

OxFord fordforox at gmail.com
Thu Jul 7 17:16:44 UTC 2016


Thanks !

2016-07-07 19:05 GMT+02:00 Marcin Mrotek <marcin.jan.mrotek at gmail.com>:

> Hello,
>
> > Why is there no default O(1) random access list data structure in haskell
> > (for example clojure has [] vector). I would expect that this kind of
> data
> > structure is used very often, so you shouldn't need to import one
> yourself.
>
> Vector (https://hackage.haskell.org/package/vector) can be considered
> standard for all intents and purposes; it's one of the core libraries
> (https://wiki.haskell.org/Library_submissions#The_Libraries).
> Containers in Haskell are in general imported as libraries, it's no
> different than Map, Set, or Sequence, for example. I'm not sure if
> it's used all that often in Haskell - it's excellent for numeric code,
> or other cases when one just needs a big dumb block of data (though
> streaming with pipes or conduit might be a better solution in some
> cases), but for otherwise something like IntMap or Sequence might be
> more useful.
>
> >Why is array indexeded by ! and list by !!. Shouldn't they be both
> instances of something like Indexable?
>
> Indexing a list is O(n) and generally a bad idea. Proliferating type
> classes just to cover the rare use case of code that is indifferent to
> whether the indexing is done in O(n) or O(1) seems pointless to me.
>
> Best regards,
> Marcin Mrotek
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160707/40712e5e/attachment.html>


More information about the Beginners mailing list