[Haskell] Re: reflection/metadata in Haskell?

Srinivas Nedunuri nedunuri at cs.utexas.edu
Thu Sep 22 11:23:22 EDT 2005

hello Ralf, thanks for your reply. I took a look at the Scrap Your
Biolerplate paper and plan to try it out. Meanwhile there's one little
piece in that paper I didn't quite follow, and thats the definition of mkT

mkT :: (Typeable a, Typeable b) => (b -> b) -> a -> a
mkT f = case cast f of
                Just g -> g
                Nothing -> id

 From the definition of cast and the examples given earlier it looks
like cast needs to be told what the target type (a here) is in order to
know what its trying to cast to  - hence the example was "(cast
'a')::Maybe Char" - which makes sense. So I dont quite understand the
usage of cast presented here inside mkT. How does the case proceed
without knowing what its trying to cast f to?


"Ralf Lammel" <ralfla at microsoft.com> wrote in message
news:1152E22EE8996742A7E36BBBA7768FEE07203433 at RED-MSG-50.redmond.corp.micros
I would rather argue that:
- Template Haskell approx. *compile-time* reflection
- Scrap your boilerplate II (ICFP 2004) approx. *run-time* reflection
- Generic Haskell is effectively a Haskell generator
P.S.: Another way to get *compile-time* reflection in Haskell is of course
type-level programming as pioneered by McBride and Hallgreen ...

> -----Original Message-----
> From: haskell-bounces at haskell.org [mailto:haskell-bounces at haskell.org] On
> Behalf Of Mads Lindstrøm
> Sent: Wednesday, September 21, 2005 11:40 AM
> To: haskell at haskell.org
> Subject: Re: [Haskell] reflection/metadata in Haskell?
> ...
> I do not know of any Java-like reflection capabilities in Haskell.
> However, "Scrap Your Boilerplate" (search google) and Generic Haskell
> can do a lot of the same stuff reflection can do in Java. Think of it as
> compile-time reflection.

More information about the Haskell mailing list