Question: I am looking for a mutable (balanced) tree/map/hash table in Haskell or a way how to simulate it inside a function. I.e. when I call the same function several times, the structure is preserved. So far I have tried Data.HashTable (which is OK, but somewhat slow) and tried Data.Array.Judy but I was unable to make it work with GHC 6.10.4. Are there any other options?

Answer: 
Building on @Ramsey's answer, I also suggest you reconceive your function to take a map and return a modified one. Then code using good ol' [Data.Map](http://www.haskell.org/ghc/docs/latest/html/libraries/containers-0.3.0.0/Data-Map.html), which is pretty efficient at modifications. Here is a pattern:

```
import qualified Data.Map as Map

-- | takes input and a map, and returns a result and a modified map
myFunc :: a -> Map.Map k v -> (r, Map.Map k v)
myFunc a m = … -- put your function here

-- | run myFunc over a list of inputs, gathering the outputs
mapFuncWithMap :: [a] -> Map.Map k v -> ([r], Map.Map k v)
mapFuncWithMap as m0 = foldr step ([], m0) as
    where step a (rs, m) = let (r, m') = myFunc a m in (r:rs, m')
    -- this starts with an initial map, uses successive versions of the map
    -- on each iteration, and returns a tuple of the results, and the final map

-- | run myFunc over a list of inputs, gathering the outputs
mapFunc :: [a] -> [r]
mapFunc as = fst $ mapFuncWithMap as Map.empty
    -- same as above, but starts with an empty map, and ignores the final map

```

It is easy to abstract this pattern and make mapFuncWithMap generic over functions that use maps in this way.
> 
> Are there any other options?
> 
> 
> 

A mutable reference to a purely functional dictionary like `Data.Map`.