[Haskell-cafe] Function to cast types
Anonymous Anonymous
temp.public at gmail.com
Sun Mar 22 09:20:26 EDT 2009
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090322/0b9e338d/attachment.htm
More information about the Haskell-Cafe
mailing list