Hi haskellers,<br><br>I have a few problems using monad transformers. I have such two functions:<br><br>parseSyslog :: StateT Integer Parser TimeStamp<br>parseString :: StateT Integer Parser LogString<br><br>and the following code:<br>
parseString = do<br>  -- string parse here, all in the form of lift $ &lt;parser&gt;<br>  stamp         &lt;- lift $ lexeme parseTimestamp -- &lt;?&gt; &quot;timestamp&quot;<br>  message     &lt;- lift $ manyTill anyToken eof    -- &lt;?&gt; &quot;message&quot;<br>
return (LogString &lt;...parsed values here...&gt; (check stamp console message) &lt;...more parsed values here...&gt;)<br>      where check :: (Maybe TimeStamp) -&gt; Console -&gt; String -&gt; Maybe TimeStamp<br>                check Nothing Syslog message = case (lift parse $ parseSyslog &quot;&quot; message) of<br>
                                             Left  err -&gt; Nothing<br>                                             Right res -&gt; Just res<br>                &lt;...other clauses here...&gt;<br><br>this code seems quite intuitive to me, however it doesn&#39;t compile with a king error:<br>
<br>    Couldn&#39;t match kind `(* -&gt; *) -&gt; * -&gt; *&#39; against `?? -&gt; ? -&gt; *&#39;<br>    When matching the kinds of `t :: (* -&gt; *) -&gt; * -&gt; *&#39; and<br>                               `(-&gt;) :: ?? -&gt; ? -&gt; *&#39;<br>
    Probable cause: `lift&#39; is applied to too many arguments<br>    In the first argument of `($)&#39;, namely `lift parse&#39;<br><br>I&#39;m not so familiar with monad transformers whatsoever, so I&#39;ll be very happy if someone can show me the right way. The code compile nicely if I use &quot;parse&quot; line in a such way:<br>
<br>check Nothing Syslog message = case (parse (evalStateT parseSyslog 0) &quot;&quot; message) of<br><br>but this is not what I really want. To be accurate, here is the sequence which I do want to have in the code:<br><br>
some user state is initialized; parseString gets called many times and changes the state via call to the parseSyslog (that is the only function that really uses/affects user state, everything else is pure Parsec code with it&#39;s own internal state). Two main problems that I have now is:<br>
<br>1) impossibility to use parse/parseTest functions with the (StateT &lt;state type&gt; Parser &lt;parse type&gt;) argument. I want it to be lifted somehow, but cannot see how<br>2) too many lifts in the code. I have only one function that really affects state, but code is filled with lifts from StateT to underlying Parser<br>
<br>Sorry if the questions are silly; any help is appreciated<br><br>-- <br>Regards, Paul Sujkov<br>