Template Haskell reification

Simon Peyton-Jones simonpj@microsoft.com
Mon, 6 Jan 2003 09:29:25 -0000

| Why is it that one can't reify top level function declarations? At the
| moment it only seems that we can reify type declarations.  No
| reason for this seems to spring to mind, but there may be one.

[I'm interested to know something about your application, incidentally.]

Several reasons conspire. =20

a) Inconvenience (it's a little tiresome to implement)

b) It would be particularly difficult to get the definition of a
function defined in another module (because we'd have to read that
entire module too).  This is not true of data type declarations, which
travel in interface files, so there is no ugly cross-module issue to
worry about. =20

c) I'm not quite clear what you'd expect to get.  If we have

	f =3D ...f...

it's easy enough.  If you have mutual recursion

	f =3D ...g...
	g =3D ...f...

do you get just f's definition, or g's too?  If it's a pattern binding

	(f,g) =3D ...

you can't avoid getting both. =20

And even if it's a simple, non-recursive defn

	f =3D ....g....

(where g is defined earlier), I wonder whether there should be some way
to get at g's definition too.