<div dir="ltr">Hi <span style="font-family:arial,sans-serif;font-size:13px;font-weight:bold;white-space:nowrap">Angus, </span><div><font face="arial, sans-serif"><b style="white-space:nowrap"> </b></font></div><div><font face="arial, sans-serif"><span style="white-space:nowrap">   Your understanding is correct. Parenthesis is need in a -> a to specify that it is function from a to a because associativity of -> is from right to left. (*2) is section, you can read more</span></font></div>

<div><font face="arial, sans-serif"><span style="white-space:nowrap">   about here : </span></font><a href="http://www.haskell.org/haskellwiki/Section_of_an_infix_operator">http://www.haskell.org/haskellwiki/Section_of_an_infix_operator</a>. </div>

<div>   </div><div><font face="arial, sans-serif"><span style="white-space:nowrap">   Type of (*2) is (Num a) :: a -> a rather than particular type Int.</span></font></div><div><font face="arial, sans-serif"><span style="white-space:nowrap"> </span></font></div>

<div><font face="arial, sans-serif"><span style="white-space:nowrap"><br></span></font></div><div><font face="arial, sans-serif"><span style="white-space:nowrap">Thanks</span></font></div><div><font face="arial, sans-serif"><span style="white-space:nowrap">Divyanshu Ranjan</span></font></div>

<div><font face="arial, sans-serif"><span style="white-space:nowrap"><br></span></font></div><div><font face="arial, sans-serif"><span style="white-space:nowrap"><br></span></font><div><span style="font-family:arial,sans-serif;font-size:13px;font-weight:bold;white-space:nowrap"> </span></div>

</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Dec 31, 2013 at 8:16 PM, Angus Comber <span dir="ltr"><<a href="mailto:anguscomber@gmail.com" target="_blank">anguscomber@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">iterate' :: (a -> a) -> a -> [a]<br><div><br></div><div>I am trying going to go ahead and write my own iterate function.  But before I do I want to be clear on types.</div>

<div><br></div><div>Looking at  :: (a -> a) -> a -> [a]</div>
<div><br></div><div>The first part is (a -> a)  Now because it is in parentheses it is a function?</div><div><br></div><div>I can call iterate like this:</div><div><div>take 5 $ iterate (*2) 5</div></div><div><br></div>


<div>So (*2) is a possible function.  Does the brackets mean it is a function, the left hand a is indicating a general type and the right hand a means the return type must be the same as the function type.  Eg in the case of (*2) the 2 is an Int so the function returns and Int?  Is my understanding correct?</div>


<div><br></div><div>How could this be better explained?</div><div><br></div><div>The last bit is easier to understand.  a -> [a] meaning a singleton of general type and [a] means a list of same type.</div><div><br></div>


<div><br></div><div><br></div><div><br></div><div><br></div></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>