
Hello, let's say I'm defining function that does the following: ShowFloat -> Floating -> String, at what kind of userinput (assuming you insert some floating number) will I get an error? (Please do not post overflow, because I already know that =)). Thanks for your help again guys!

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. Regards, Roel

Hello,
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,
J.T.K.M.
2009/11/27 Roel van Dijk
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.
Regards, Roel

Hello,
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
Hello,
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,
J.T.K.M.
2009/11/27 Roel van Dijk
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.
Regards, Roel

Hi Tsun,
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.
I believe you got that problem from the function showCC in Ex. 6 in my assignment ( http://www.cs.uu.nl/wiki/FP/Practicum#PracticumOne ), since you're in my course. However it asks me how my function can fail?
I want to know how, given the function's type, it can fail. This is particular to your definition. This is different from using the function on an expected type. That is not a case of the function failing but a case of the typechecker telling you the program is invalid. Are there any values of Integer for which showCC produces an unexpected output? What about negative numbers, large numbers, etc? What does your function do for these cases? I didn't ask you to do any error checking, so instead, I want you to tell me the limits of your function definition. 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)
The function is strict, so undefined would cause it to fail. I'm not really concerned with that kind of answer, because we aren't working with these values in the course, yet.
At this moment I really can't figure out how my function can fail other than the inputs described above.
AFAIKT, you just mentioned Float. This is a type mismatch, not a case in which showCC fails or provides unexpected output.
Thanks for your help!
I'm glad that you're being creative with how you're asking questions. I hope you have been taking advantage of the werkcollege and practicum sessions, too. Just so you know, there are some guidelines about asking homework questions on the mailing lists. http://www.haskell.org/haskellwiki/Homework_help Don't forget: the deadline is tonight at 23:59. Good luck! Regards, Sean

Tsunkiet Man
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
The compiler guarantees that this will not happen, thus your function will not get the opportunity to fail.
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:
The numbers closest to zero that you are able to pass, are 1 and -1. Both of which should work, no?
Now I also know that when I use 'undefined' I would get an error.
I'd argue that it's not your function that fails, but the parameter (whose evaluation causes an exception).
So what other cases are there?
Well, it might fail to terminate (loop forever). Semantically, I think this is treated as _|_ just like passing it 'undefined'. I think you'll have a hard time doing this with 'show', though.
(I asked my question about Floating because I guessed it would be similiar to Integers)
Floating point (IEEE 754) has its own set of problems, but in general, I think 'show' is fairly robust. But perhaps you can you think of a resource it can run out of? -k -- If I haven't seen further, it is by standing in the footprints of giants
participants (4)
-
Ketil Malde
-
Roel van Dijk
-
Sean Leather
-
Tsunkiet Man