haskell-handbook
haskell-handbook copied to clipboard
How to use actual arrays, 1D or 2D, with O(1) access and mutation complexity
I still don't know how to work with arrays in Haskell that are fast like in other languages! I would like to write a tutorial that explains this but for the beginners, and is as simple as possible, not assuming you know what ST monad is and similar, but instead shows with very good examples how to do it -> ideally I would just follow those examples and get it done.
I asked a bit around and was told that this probably has to do with ST monad, so maybe I should look in that direction.
I also found out there are Vector and Array libraries which can serve for this although the are somewhat different.
Some potential resources:
- https://www.reddit.com/r/haskell/comments/1031s81/optimising_haskell_2_swapping_set_for_array/?utm_source=share&utm_medium=android_app&utm_name=androidcss&utm_term=2&utm_content=share_button
Potential name of the blog post: "Beyond Lists".
Vectors are intersting, since they have O(1) access. But mutation is still not O(1). Certainly address them though.