a universal printer for Haskell?

Ashley Yakeley ashley@semantic.org
Tue, 19 Feb 2002 17:35:22 -0800


At 2002-02-19 09:56, Richard Uhtenwoldt wrote:

>>This is reflection! I'd rather not have Haskell contaminated with such 
>>things; 
>
>Can you say a little more about why you think reflection is bad?
>Does it make the language implementation run slower?

It's ugly, and isn't part of the spirit of the language. You shouldn't be 
able to peer into types that way. If you decide to change the private 
structure of your types, you shouldn't have to worry about what effects 
it will have on the rest of the program.

Consider:

    module A (Thing()) where
        {
        data Thing = MkThing Char;
        }

    module B where 
        {
        import A;
        peek :: Thing -> Char;
        peek thing = (\(MApp _ (MChar c)) -> c) (reify thing);
        }

B can look inside a private structure of A. The problem is not the Reify 
class, but the compiler's autogeneration of instances.

>(I'd ask via private email, but when I emailed you in the past
>I didn't get a reply.)

That sounds like me...

-- 
Ashley Yakeley, Seattle WA