[Haskell-cafe] Show function a -> String

Sean Leather leather at cs.uu.nl
Fri Nov 27 09:18:29 EST 2009

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.


Don't forget: the deadline is tonight at 23:59. Good luck!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091127/896f3ca5/attachment.html

More information about the Haskell-Cafe mailing list