<br>I am learning Haskell working through Simon Thompson book "Haskell The Craft of Functional Programming" (second edition). Solving problems in the book with more or less success I arrived almost to the end of the book at the section 
17.5 "Case study: parsing expressions".<br>Most probably the question I am going to ask here is very stupid, so please bear with me. In any case, after going so far in the book I felt certain that I know what function declaration means. So I thought that declaration:
<br><br>F :: a -&gt; b -&gt; c<br><br>Is the same as:<br><br>F :: a -&gt; (b -&gt; c)<br><br>And means either:<br><br>-&nbsp;&nbsp;&nbsp; a function 'f' of one argument of type 'a' that returns a function of type (b -&gt; c), or it can also be interpreted as:
<br>-&nbsp;&nbsp; &nbsp;a function 'f' of two arguments of type 'a' and 'b' returning value of type 'c'<br><br>Now, in the 17.5 section of a book one may see the following declarations:<br><br>succeed :: b -&gt; Parse a b<br><br>*Before looking at 'succeed' function definition* one may think that 'succeed' is a function of *one* argument of type 'b' that returns object of type 'Parse a b'.
<br><br>Yet, function definition given in the book is:<br><br>succeed val inp = [(val, inp)]<br><br>Looking at this definition, I am inclined to think that 'succeed' is a function of *two*&nbsp; arguments named 'val' and 'inp' in the definition !
<br>How can such a definition be correct?<br><br>Ok, lets see what is this 'Parse a b' type is:<br><br>type Parse a b = [a] -&gt; [(b, [a])]<br><br>So how does this help to make definition <br><br>'succeed val inp = [(val, inp)]'
<br><br>sound right?<br><br>Well, the only way for me to make sense out of this is as follows. <br>In this case Haskell 'type' makes type synonym for the type:<br>[a] -&gt; [(b, [a])]<br><br>In order not to get out of my mind I start thinking about 'type' as a macro substitution mechanism. Then I do this substitution *myself as a Haskell runtime* and get in the result the following declaration of a * real function that Haskell runtime* works with:
<br><br>Succeed :: b -&gt; [a] -&gt; [(b, [a])]<br><br>Great! This last declaration matches perfectly with function definition:<br><br>succeed val inp = [(val, inp)]<br><br>So I start feeling better, after all, it looks like my understanding of Haskell function declarations is not flawed too much.
<br>Well, but here comes my main questions! So:<br>1. Should I work every time as a macro translator when I just see *!any!* function declaration?<br>2. Should I search through main and imported modules for treacherous 'type' constructs?
<br>3. Where, in this case goes implementation abstraction principle? Why I must provide *all* the details about function argument type structure in order to understand how this function works? &nbsp;<br><br>Another example of a similar function from the book is:
<br><br>alt :: Parse a b -&gt; Parse a b -&gt; Parse a b<br>alt p1 p2 inp = p1 inp ++ p2 inp<br><br>In function definition I see three parameters:<br>p1 – matches with function declaration perfectly<br>p2 – matches with function declaration perfectly
<br>inp – how to match this parameter with function declaration ?<br><br>I can match 'inp' parameter with 'alt' function declaration *only* after working as macro processor that expands type synonym 'Parse a b' into '[a] -&gt; [(b, [a])]' and getting *real* declaration:
<br><br>alt :: [a] -&gt; [(b, [a])] -&gt; [a] -&gt; [(b, [a])] -&gt; [a] -&gt; [(b, [a])]<br><br>with that matches <br><br>alt p1 p2 inp = p1 inp ++ p2 inp<br><br>where 'inp' matches with *last* '[a]' argument.<br><br>It seems that life of "human macro processor" becomes really hard when not trivial functions with 'type' synonym arguments come into play!
<br>Where I am wrong? Please enlighten me; I am really at a loss!<br>And thanks for reading all this! <br>Below I give a code example of these functions.<br><br>Thanks,<br>Dima<br><br><br>module Parser where<br><br>import 
Data.Char<br><br>type Parse a b = [a] -&gt; [(b, [a])]<br><br>none :: Parse a b<br>none inp = []<br><br>succeed :: b -&gt; Parse a b<br>succeed val inp = [(val, inp)]<br><br>suc:: b -&gt; [a] -&gt; [(b, [a])]<br>suc val inp = [(val, inp)]
<br><br>spot :: (a -&gt; Bool) -&gt; Parse a a<br>spot p [] = []<br>spot p (x:xs) <br>&nbsp;&nbsp;&nbsp;&nbsp; | p x = [(x, xs)]<br>&nbsp;&nbsp;&nbsp;&nbsp; | otherwise = []<br><br>alt :: Parse a b -&gt; Parse a b -&gt; Parse a b<br>alt p1 p2 inp = p1 inp ++ p2 inp
<br><br>bracket = spot (==&#39;(&#39;)<br>dig = spot isDigit<br><br>t1 = (bracket `alt` dig) &quot;234&quot;<br><br>