Nested set model implementation in Haskell