[Haskell-cafe] Function to cast types

John Dorsey haskell at colquitt.org
Sun Mar 22 10:16:23 EDT 2009

Anonymous One,

> I'm new to haskell, I'm wondering how can you write a function that will do
> the following:
> fromIntToString :: Int -> String

Is this a homework assignment, perchance?  Please take a look at
Everyone here is glad to help, but we're also sensitive on academic

With that said, you've done the first step, which is writing down the
function's type.  You don't want to iterate over all possible Int
values, so maybe a recursive definition is in order.  What are the cases
to consider?  Like, what happens if you have a negative number...

> this is a cast function to cast an Int to a String. I know such function

By the way, "cast" is probably the wrong word for what you want.  You're
building a string representation of an Integer; in my view it's not "just"
a type conversion.

Good luck,

More information about the Haskell-Cafe mailing list