[Haskell-cafe] Show function a -> String
temp.tsun at gmail.com
Fri Nov 27 08:05:54 EST 2009
some details regarding my question. I got this assignment which gives me the
following: SomeFunction :: Integer -> String. Which uses the show function
to convert the Integer to String.
However it asks me how my function can fail? Well I know my function fails
by definition when I do not insert an Integer into SomeFunction. Like
SomeFunction 2.3425221 and now I also know that when I insert a number that
is very close to zero (I think a denormalized value means that a value is
very close to zero:
http://www.haskell.org/pipermail/libraries/2004-November/002661.html) I get
probably get an error. But that is normal as a 0.000001 * e^(-10) is not
really an Integer, right?
Now I also know that when I use 'undefined' I would get an error. So what
other cases are there? (I asked my question about Floating because I guessed
it would be similiar to Integers)
At this moment I really can't figure out how my function can fail other than
the inputs described above.
Thanks for your help!
2009/11/27 Tsunkiet Man <temp.tsun at gmail.com>
> yes that is exactly what I mean, however I mean what kind of value do I
> need to input in 'a' that gets me an error back? That is is from the
> Floating class? (Other than undefined)
> Could you please explain to me what IEEE 754 is and what exactly is a
> denormalized value? (After responding, I will google it also though).
> Thank you for your help,
> 2009/11/27 Roel van Dijk <vandijk.roel at gmail.com>
> >ShowFloat -> Floating -> String
>> I do not really understand this type.
>> Did you mean something like this:
>> showFloat :: (Show a, Floating a) => a -> String
>> showFloat = show
>> In that case it depends on what type you fill in for 'a' and more
>> specifically that type's Show instance. One value for which most (or
>> all) show functions will give an error is ⊥ (undefined). If the type
>> you pick is some kind of IEEE 754 type then you might have some
>> trouble with denormalized values. But that is just a guess, you would
>> have to test for that.
>> If that is not what you mean than I would appreciate some clarification.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe