<div dir="ltr">Bjorn,<br>I am initializing a list from a file.&nbsp; I am reading the lines from the file, splitting them into bytestring and then converting them to float.&nbsp; Should I be using String&nbsp; -&gt; Float or ByteString -&gt; Float?<br>
<br>thanks<br>Daryoush<br><br><div class="gmail_quote">On Tue, Aug 26, 2008 at 6:01 AM, Bjorn Bringert <span dir="ltr">&lt;<a href="mailto:bjorn@bringert.net">bjorn@bringert.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">2008/8/24 Daryoush Mehrtash &lt;<a href="mailto:dmehrtash@gmail.com">dmehrtash@gmail.com</a>&gt;:<br>
</div><div><div></div><div class="Wj3C7c">&gt; I am trying to convert a string to a float. &nbsp;It seems that Data.ByteString<br>
&gt; library only supports readInt. &nbsp; &nbsp;After some googling I came accross a<br>
&gt; possibloe implementation: <a href="http://sequence.svcs.cs.pdx.edu/node/373" target="_blank">http://sequence.svcs.cs.pdx.edu/node/373</a><br>
&gt;<br>
&gt; My questions are:<br>
&gt;<br>
&gt; a) is there a standard library implementation of string -&gt; Double and float?<br>
&gt; b) Why is it that the ByteString only supports readInt? Is there a reason<br>
&gt; for it?<br>
<br>
</div></div>Hi Daryoush,<br>
<br>
are you really looking for ByteString -&gt; Float conversion, or just<br>
plain String -&gt; Float? The latter is really simple, the function is<br>
called &#39;read&#39; and is available in the Prelude:<br>
<br>
$ ghci<br>
GHCi, version 6.8.3: <a href="http://www.haskell.org/ghc/" target="_blank">http://www.haskell.org/ghc/</a> &nbsp;:? for help<br>
Loading package base ... linking ... done.<br>
Prelude&gt; read &quot;3.14&quot; :: Float<br>
3.14<br>
<font color="#888888"><br>
/Bjorn<br>
</font></blockquote></div><br>/<br>
</div>