title: Parsing Indentation-based syntaxes in Haskell's Parsec
body: <p>I'm trying to parse an indentation-based language (think Python, Haskell itself, Boo, YAML) in Haskell using Parsec. I've seen the IndentParser library, and it looks like it's the perfect match, but what I can't figure out is how to make my <code>TokenParser</code> into an indentation parser. Here's the code I have so far:</p>
  
  <pre><code>import qualified Text.ParserCombinators.Parsec.Token as T
  import qualified Text.ParserCombinators.Parsec.IndentParser.Token as IT
  
  lexer = T.makeTokenParser mylangDef
  ident = IT.identifier    lexer
  </code></pre>
  
  <p>This throws the error:</p>
  
  <pre><code>parser2.hs:29:28:
      Couldn't match expected type `IT.TokenParser st'
               against inferred type `T.GenTokenParser s u m'
      In the first argument of `IT.identifier', namely `lexer'
      In the expression: IT.identifier lexer
      In the definition of `ident': ident = IT.identifier lexer
  </code></pre>
  
  <p>What am I doing wrong? How should I create an <code>IT.TokenParser</code>? Or is IndentParser broken and to be avoided?</p>