[Haskell-cafe] Reification in Haskell, was: To yi or not to yi

Bulat Ziganshin bulat.ziganshin at gmail.com
Thu Jun 21 07:27:13 EDT 2007

Hello Pasqualino,

Thursday, June 21, 2007, 11:22:19 AM, you wrote:

more or less. there are Data and Typeable classes that provides this
information but to use them you

1) should use GHC
2) should add "deriving Typeable" clause to declaration of each type
you need to inspect
3) have "Typeable a" condition in definition of each function where
you need this information:

print_type :: (Typeable a) =>  a -> IO ()

so, its just something like class definition:

class Typeable a where
  typename :: a -> String

with GHC automatically deriving instances of this class. no real RTTI
because Haskell data items are not objects. i suggest you to read
paper before asking more questions :)

> do you mean that as the type information is used only at compilation time and
> then thrown away there is no way of getting it back at execution time?

> best,

>     titto

> On Wednesday 20 June 2007 16:33:12 Bulat Ziganshin wrote:
>> Hello Pasqualino,
>> Wednesday, June 20, 2007, 11:30:32 AM, you wrote:
>> >> > Most languages, even Java, have a reflection capability to dynamically
>> >> > inspect an object. It is surprising that Haskell doesn't offer it.
>> how about asm? :)  there are no OOP objects in Haskell, each name is
>> just an address of memory area. all operations are checked statically
>> (at compile time). reflection capabilities may be only handmade - you
>> can get any type info via hidden class dictionary (see
>> http://homepages.inf.ed.ac.uk/wadler/papers/class/class.ps.gz for
>> details of type classes implementation)

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list