<div>Hi,</div>
<div>    What I&#39;m trying to do is create a parser so as when I enter say 1+1 it will return Add(Val 1)(Val 1). A couple of questions do I have to state three basic parser. As in item, fail, synbol and then combine them with below. And by the way the one below seems to be all wrong.</div>

<div> </div>
<div> </div>
<div> </div>
<div>parse  :: String -&gt; expr<br>parse expr = [(expr,string)]</div>
<div>expr :: Parser value<br>expr =  do t &lt;- term<br>  do char &#39;+&#39;<br>  e &lt;- expr<br>    return Add (Val t)(Val e)<br> +++ return t</div>
<div> </div>
<div>(+++) :: Parser a -&gt; Parser a -&gt; Parser a<br>t +++ w  inp  = case t inp of<br>     []  -&gt;  w inp<br>     [(v,out)] -&gt; [(v,out)]<br></div>
<div> </div>
<div> </div>
<div>This is what I mean by item fail and symbol</div>
<div> </div>
<div>type Parser s a = [s] -&gt; [(a,[s])]<br>item [] = []<br>item (c:cs) = [(c,cs)]</div>
<div>pFail :: Parser s a<br>pFail = \cs -&gt; []</div>
<div>pSymbol :: Eq s =&gt; s -&gt; Parser s s<br>pSymbol a (b:bs) |a == b = [(b,bs)]<br>  |otherwise = []<br></div>
<div> </div>
<div>I know this is a bit of a mess, but could someone explain where I should start and if I should use any of the code above. Also to point out I want to write the complete parser without using prelude and other built in functions as I will be changing as I go.</div>

<div> </div>
<div>John</div>