At 06:33 PM 7/24/00 +1000, Fergus Henderson wrote:
>On 24-Jul-2000, Chris Angus <[EMAIL PROTECTED]> wrote:
>> Has anyone ever thought of trying to use reflection in these cases.
>
>Yes, I've thought of it. That is how we implement the generic
>`read' and `print' in Mercury. Using reflection like this
>seems to be a quite powerful technique; I think that using
>reflection you can do quite a lot in the language that in Haskell
>currently seems to instead be done with external preprocessors
>(e.g. "Deriv", or whatever it is called now).
Yes, reflection is a powerful technique, with which you can define zip,
show, read, etc. However, I think for this kind of applications it is
better to apply generic programming techniques, which give you type-safety
(and hence no run-time problems), and compile-time code generation (or
partial evaluation). See for how to define these functions in PolyP or
Generic Haskell:
Ralf Hinze. A Generic Programming Extension for Haskell. In Erik Meijer,
editor, Proceedings of theThird Haskell Workshop, Paris, France, September
1999. The proceedings appear as a technical report of Universiteit Utrecht,
UU-CS-1999-28.
http://www.informatik.uni-bonn.de/~ralf/publications.html
P. Jansson and J. Jeuring. Polytypic data conversion programs. Submitted
for publication, 2000.
http://www.cs.uu.nl/~johanj/publications/publications.html
And for generic programming in general:
R. Backhouse, P. Jansson, J. Jeuring, and L. Meertens. Generic Programming
- An Introduction -. In S.Doaitse Swierstra, Pedro R. Henriques and Jose
N. Oliveira, editors, Advanced Functional Programming, LNCS 1608, pages
28--115, Springer-Verlag, 1999.
also available via my publications page.
-- Johan Jeuring