
22 Mar
2009
22 Mar
'09
9:20 a.m.
Hello, I'm new to haskell, I'm wondering how can you write a function that will do the following: fromIntToString :: Int -> String this is a cast function to cast an Int to a String. I know such function exist, however let's assume it didn't exist. How would I write such function? Cause I have no idea, because there are infinity possibilities if I do it like: fromIntToString x | x == 1 = "1" | x == 2 = "2" -- And so on... I've also thinked about defining the defining the data types Int and String (I know you cannot redefine them, at least I think so), however I've no succes. Thank you in advance for answering my question! PS: if possible please do not use any casting functions that are predefined.