[Haskell-cafe] Is it possible to get the information of instances of a type?

Ertugrul Soeylemez es at ertes.de
Wed Oct 26 16:17:47 CEST 2011

Magicloud Magiclouds <magicloud.magiclouds at gmail.com> wrote:

>   If this was in ruby or other languages that support reflection, it
> won't be a question.
>   But in Haskell, could I write a code to list the classes that a type
> instanced?

In regular Haskell, type information is completely lost after
compilation, so you can't recover any of that.  There is no run-time
type information like in languages with OO inheritance.

However, types can choose to provide type information through the
Typeable type class (Data.Typeable).  Generally you wouldn't want to use
it, if you write Haskell properly (i.e. if you don't try to write Ruby
in Haskell).

>   TemplateHaskell as well.

I'm not sure about that one.


nightmare = unsafePerformIO (getWrongWife >>= sex)

More information about the Haskell-Cafe mailing list