import StateParser

pAB = do pSym 'a'; modify (+1); pAB
  <|> do pSym 'b'; n <- pAB; return (n+1)
  <|> pSucceed 0

test = map (\ (b,a,_) -> (a,b)) . filter (\ (_,_,ts) -> null ts) . parse pAB 0
  

