title: Text.ParserCombinators
body: <p>I want to make a parser combinator for regular expressions in  Haskell. So I defined my own data type and made a match function for this type. I recently discovered about Text.ParserCombinators. If I use <code>parseTest</code> function the result type is <code>IO</code>. So how do I use Text.ParserCombinators to return the type of my created data? Below is my code.</p>
  
  <pre><code>data Reg = Eps
          |Sym Char --caracter
          |Alt Reg Reg --a sau b a|b
          |Seq Reg Reg -- secventa ab  sau chiar paranteza
          |Rep (Int, Maybe Int) Reg   --Star repet on or more time
          |Dif Reg    --not
  deriving (Show)
  --match function
  accept :: Reg -&gt; String -&gt;Bool
  
  accept ( parse term "abcd") "abcd"
  ERROR - Type error in application
  *** Expression     : accept (parse term "abcd") "abcd"
  *** Term           : parse term "abcd"
  *** Type           : [Char] -&gt; Either ParseError Reg
  *** Does not match : Reg
  --term is the Parser function where the grammars is defined
  term :: Parser Reg
  term = buildExpressionParser ops atom where    
  </code></pre>