Representing cyclic data structures efficiently in Haskell