
What is the best way to implement data structures that use pointers in Haskell? My first thought is as follows. Suppose for simplicity the labels are just integers, and each object need to point to one other one. I would have a getObject:: Int -> a f:: Int -> Int But I don't understand how Haskell maintains functions in memory, and in particular whether lookup/update is efficient. So suppose I define a f f x = case x of 1 -> 2 2 -> 3 .... (etc.) Q: if there are n entries here, how long does looking up (f m) take? Suppose later I update, with something like this: update::Int->Int->(Int->Int)->(Int->Int) update x y f z = (if z==x then y else f x) Q: how is "update x y f" maintained? Is using a f::Int->Int like using a pointer in terms of time complexity, and if not, what data structure should I use instead? Thanks, Holden