Hi,<br><br>well you&#39;re using the IO Monad all over the place. Instead I 
suggest using it only in certain places (like main) and keep the 
functions pure in general. One way to improve this might be to start 
from the inside and first think about what functions you need and then 
what the types should look like. For example you need a function to add a
 student to the list, the type of pure function which does that looks 
like this:<br>
<i>aadd :: [Student] -&gt; Student -&gt; [Student]</i><br>Then implement
 this function and think from the outside: Given some user input, how 
can I create a student? Take a look at this[1] page.. you&#39;ll find a 
suggestion on how to improve your <i>ashow</i> function there.<div class="im"><br>
<br><i><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font>loop $ <font>(Student $ read id $ read name), is wrong why?</font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></i><br>

</div>
That operator you are using three times there basically says: &quot;Evaluate the right thing first&quot;, so what you end up with after <i>read name</i> has been evaluated is <i>read id (read name)</i>. Once you understand that, you&#39;ll also find that the braces are unnecessary (though not wrong).<br>


<br>If you want to avoid the IO Monad in general then I suggest you &quot;test&quot; your program with GHCI.<br><br>I&#39;m sure you&#39;ll also find examples for basic input-dialog haskell programs in either <i>Learn You a Haskell[2] for Great Good</i> or <i>Real World Haskell</i>[3].<br>


<br>1: <a href="http://learnyouahaskell.com/types-and-typeclasses" target="_blank">http://learnyouahaskell.com/types-and-typeclasses</a><br>2: <a href="http://learnyouahaskell.com/" target="_blank">http://learnyouahaskell.com/</a><br>

3: <a href="http://book.realworldhaskell.org/" target="_blank">http://book.realworldhaskell.org/</a><br>
<br>Cheers,<br>Reto<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Dec 2, 2012 at 1:43 PM, Ezequiel Hernan Di Giorgi <span dir="ltr">&lt;<a href="mailto:hernan.digiorgi@gmail.com" target="_blank">hernan.digiorgi@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


        
        
        
        


<pre style="background:#ffffff"><font color="#141312"><span style="font-family:arial,helvetica,sans-serif"><font>H<font>ola! Hallo!<br><font>I<font> made <font>my first program to understand lists and <font>something about da<font>tat types. I have some question about the fol<font>lowin<font>g code...</font></font></font></font></font></font></font></font></font></span></font><br>



<b><br><br>import</b> <font color="#0057ae">Data.List</font>

<font color="#141312"><b>data</b> <font color="#0057ae">Student</font> <font color="#452886">=</font> </font>
<font color="#141312">     <font color="#0057ae">Student</font> {<font color="#006e28"> id     ::</font> <font color="#0057ae">Int</font>,</font>
<font color="#141312"><font color="#006e28">               nombre ::</font> <font color="#0057ae">String</font></font>
<font color="#141312">             } <b>deriving</b> (<b>Show</b>, <b>Eq</b>)</font>

<font color="#141312"><font color="#006e28">main ::</font> <font color="#0057ae">IO</font> ()</font>
<font color="#141312">main <font color="#452886">=</font> <b>do</b> <font color="#452886">putStrLn</font> <font color="#bf0303">&quot;---\nStudent Magnament Program\n---&quot;</font></font>
<font color="#141312">          loop []</font>
<font color="#141312"> </font>
<font color="#141312"><font color="#006e28">ashow ::</font> [<font color="#0057ae">Student</font>] <font color="#006e28">-&gt;</font> <font color="#0057ae">IO</font> ()</font>
<font color="#141312">ashow []    <font color="#452886">=</font> <font color="#452886">putStrLn</font> <font color="#bf0303">&quot;Empty list&quot;</font></font>
<font color="#141312">ashow [x]   <font color="#452886">=</font> <font color="#452886">putStrLn</font> <font color="#452886">$</font> <font color="#452886">show</font> x</font>
<font color="#141312">ashow (x<font color="#452886">:</font>xs)<font color="#452886">=</font> <b>do</b> <font color="#452886">putStrLn</font> <font color="#452886">$</font> <font color="#452886">show</font> x</font>
<font color="#141312">                 ashow xs</font>
<font color="#141312"> </font>
<font color="#141312"><font color="#006e28">aadd ::</font> [<font color="#0057ae">Student</font>] <font color="#006e28">-&gt;</font> <font color="#0057ae">IO</font> ()</font>
<font color="#141312">aadd xs <font color="#452886">=</font> <b>do</b> <font color="#452886">putStrLn</font> <font color="#bf0303">&quot;Enter the id&quot;</font></font>
<font color="#141312">             <font color="#452886">id</font> <font color="#006e28">&lt;-</font> <font color="#452886">getLine</font></font>
<font color="#141312">             <font color="#452886">putStrLn</font> <font color="#bf0303">&quot;Enter name&quot;</font></font>
<font color="#141312">             name <font color="#006e28">&lt;-</font> <font color="#452886">getLine</font></font>
<font color="#141312">             loop <font color="#452886">$</font> (<font color="#0057ae">Student</font> (<font color="#452886">read</font> <font color="#452886">id</font>) (<font color="#452886">read</font> name) ) <font color="#452886">:</font> xs</font>
<font color="#141312">             </font>
<font color="#141312"><font color="#006e28">aremove ::</font> [<font color="#0057ae">Student</font>] <font color="#006e28">-&gt;</font> <font color="#0057ae">IO</font> ()</font>
<font color="#141312">aremove xs <font color="#452886">=</font> <b>do</b> <font color="#452886">putStrLn</font> <font color="#bf0303">&quot;Enter the id&quot;</font></font>
<font color="#141312">                <font color="#452886">id</font> <font color="#006e28">&lt;-</font> <font color="#452886">getLine</font></font>
<font color="#141312">                <font color="#452886">putStrLn</font> <font color="#bf0303">&quot;Enter name&quot;</font></font>
<font color="#141312">                name <font color="#006e28">&lt;-</font> <font color="#452886">getLine</font></font>
<font color="#141312">                loop <font color="#452886">$</font> delete (<font color="#0057ae">Student</font> (<font color="#452886">read</font> <font color="#452886">id</font>) (<font color="#452886">read</font> name) ) xs</font>
<font color="#141312">             </font>
<font color="#141312"> </font>
<font color="#141312"><font color="#006e28">loop ::</font> [<font color="#0057ae">Student</font>] <font color="#006e28">-&gt;</font> <font color="#0057ae">IO</font> ()</font>
<font color="#141312">loop xs <font color="#452886">=</font> <b>do</b> <font color="#452886">putStr</font> <font color="#452886">$</font> <font color="#bf0303">&quot;\n-------\nSelect an option\n&quot;</font></font>
<font color="#141312">                        <font color="#452886">++</font> <font color="#bf0303">&quot;1) Add student\n&quot;</font></font>
<font color="#141312">                        <font color="#452886">++</font> <font color="#bf0303">&quot;2) Remove student\n&quot;</font></font>
<font color="#141312">                        <font color="#452886">++</font> <font color="#bf0303">&quot;3) Show all students\n&quot;</font></font>
<font color="#141312">                        <font color="#452886">++</font> <font color="#bf0303">&quot;4) Exit\n&quot;</font></font>
<font color="#141312">                        <font color="#452886">++</font> <font color="#bf0303">&quot;\t Your option: &quot;</font></font>
<font color="#141312">             option <font color="#006e28">&lt;-</font> <font color="#452886">getLine</font></font>
<font color="#141312">             <font color="#452886">putStrLn</font> <font color="#bf0303">&quot;\n------&quot;</font></font>
<font color="#141312">             <b>case</b> <font color="#452886">read</font> option <b>of</b></font>
<font color="#141312">                  <font color="#b08000">1</font> <font color="#006e28">-&gt;</font> aadd xs</font>
<font color="#141312">                  <font color="#b08000">2</font> <font color="#006e28">-&gt;</font> aremove xs</font>
<font color="#141312">                  <font color="#b08000">3</font> <font color="#006e28">-&gt;</font> <b>do</b> ashow xs</font>
<font color="#141312">                          loop xs</font>
<font color="#141312">                  <font color="#b08000">4</font> <font color="#006e28">-&gt;</font> <font color="#452886">putStrLn</font> <font color="#bf0303">&quot;God bye!&quot;<br><br><br></font></font></pre><font>My qu<font>estion are:<br>



</font></font><ul><li><font>W<font>hen i ask for the dat<font>a f<font>of a<font> student <font>i r<font>epe<font>at the code, cause i <font>have to use fuctions <font>using IO (), cuase i <font>have to put something in the screen. Theref<font>ore i can<font>t have a fuction that only ret<font>urn a <font>Student.</font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></li>



<li><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font>loop $ <font>(Student $ read id $ read name), is wrong why?</font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></li>



<li><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font>i <font>think that there are best <font>way to achive that i <font>h<font>ave done. Or is ok for a begginer that doesn&#39;t know f<font>unctors or </font>monads.</font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></li>



</ul><p><br></p><p><font>Sorry for my bad english, i am</font><span lang="en"><span> Argentinean.</span></span></p><p><span lang="en"><span>Thanks in advance.<br>

</span></span></p>

<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>