Generalized LR implementation in Haskell