Haskell implementation of a worst-case O(1) persistent deque