How to convert the type signature of a variable to a String?

Andrew J Bromage andrew@bromage.org
Sun, 15 Apr 2001 14:20:01 +1000


G'day all.

Mon, 9 Apr 2001 11:52:47 +0200, Pasch, Thomas (ACTGRO) <extern.thomas.pasch@volkswagen.de> pisze:

> > For example:
> > 
> >  'function f' gives the String "a->a" 

On Sat, Apr 14, 2001 at 08:28:16PM +0000, Marcin 'Qrczak' Kowalczyk wrote:

[...]
> In this form it's not even theoretically consistent: any function
> can be treated as a function of a more specific type, so the result
> would be ambiguous (for example f has type Int->Int too, so asking
> for a type should give "Int->Int" too).

I think I understand what you're saying, but I'd just like to understand
this practically.  We know that the most general type of `id' is "a->a".
We assume there's a theoretical function:

	get_the_function_type_of :: a -> String

where a can be a function type.  Now consider:

	f :: (String -> String) -> String
	f g = g (get_the_function_type_of g)

The question is: Should `f id' return "a->a" or "String->String"?

Cheers,
Andrew Bromage