help!

Sebastian Sylvan sylvan@dtek.chalmers.se
Mon, 18 Aug 2003 02:13:26 +0200 (MEST)


On Mon, 18 Aug 2003, Trouble ... wrote:

> How do I translate a string into an integer. 

You can use the overloaded function read for this...

read "4" would give 4

This function will convert any string into any value (as long as the
string is properly formatted and the value implements the function), BUT
this assumes that there is a way for haskell to figure out WHAT type of
value you wish to read from the string. 

Most of the time the way you use the resulting value will be more than
enough for Haskell to figure out that it is indeed an Int that is supposed
to be read, otherwise you'll have to explicitly write out the type
signature of that function.


--

 ----------------------------------------
|  Sebastian Sylvan                      |
|  ICQ: 44640862                         |
|  Tel: 073-6818655 / 031-812 817        |
|                                        |
|                                        |
| Hard Work Often Pays Off After Time    |
| But Laziness Always Pays Off Now!      |
 ----------------------------------------