[Haskell-beginners] using "read"

Luca Ciciriello luca_ciciriello at hotmail.com
Fri Jan 15 13:49:40 EST 2010


Hi All.

in the function:

func :: String -> Int
func str = read str

An absolute beginner as i am, want to use "read" to convert a String in a Int, but I don't know how to protect my function func from an exception when str is not a number like "12A". How can I do?

Thanks in advance for any answer to this my simply question.

Luca.


More information about the Beginners mailing list