[Haskell-cafe] New to Haskell

Benja Fallenstein benja.fallenstein at gmail.com
Wed Dec 19 02:25:15 EST 2007


Hi Paul,

On Dec 19, 2007 6:54 AM, Paul Hudak <paul.hudak at yale.edu> wrote:
>  Your version of the answer is in fact correct, but is just an elaboration
> of the original one.
>  So, I don't see what your point is...

Ok, sorry, I'll try again... I'm trying to say that in my opinion,
it's important to include the elaboration if you want to give a
*useful* answer to "why can't I print functions." :)

>>  If you can show and enumerate the argument type and show the result
>> type of a function, one way is to enumerate the graph of the function.
>
>  Yes, but this requires a STANDARD way to do this -- meaning that the
> underlying domains are enumerable in a standard way.  I don't think that is
> always possible.

It isn't always, no; in Haskell, there's no way to enumerate the
instances of (IO Int), for example. But of course, you can't show (IO
Int) in the first place, so I guess there's no expectation that you
should be able to show functions with (IO Int) arguments, either.

Function domains also aren't enumerable in general, although you could
simply enumerate all functions writable in Haskell, and not care about
duplicates. But it seems very unlikely anyway that printing
higher-order functions in this way would be *practical*.

> And of course you may have an infinite graph, whereas the
> function itself is finite.

(you mean that the function term is finite, I suppose) Yes, but you
can show infinite lists, too -- resulting in an infinite String being
returned by 'show.'

>  Regarding the rest of your message: I don't see how this helps, since some
> terms do not have head-normal forms.

But these terms denote bottom. Compare (show (1:2:_|_)); the behavior
would be similar.

> Even in the pure lambda calculus there
> are terms that denote the same value but that are not convertible to one
> another.

Such terms would return the same *infinite* String in this approach.
You couldn't write a program to test whether they're equal; but you
can't write a program that tests whether two arbitrary infinite lists
are equal, either.

> It seems that at best this approach would yield only partial
> success.

Oh, that's certainly true, in the sense that showing functions in this
way would often not be as practical as one might hope for -- the worst
problem being that recursive functions will often have infinite
representations.

Still, in my opinion, there is a difference between "the theory says
you can't show functions" and "from the theoretical perspective, there
is an elegant way to show functions, but it would be a lot of work to
implement and the result wouldn't be as practical as you're hoping
for." Although I admit it's more of a theoretical difference than a
practical one. :-)

- Benja


More information about the Haskell-Cafe mailing list