[Haskell-cafe] cast to specific Typeclass

Teodor Vlasov teodor.vlasov at gmail.com
Fri May 15 18:59:37 UTC 2015

Hello everyone,

I'm trying to implement traversal over data structures and found
Data.Typeable very useful for that. But it seems to be impossible to
cast to specific typeclass, so that we can cast Typeable to something
that is Show'able for example. It'd be usefull to have something like:

data CanShow = forall a. CanShow a

toConcrete :: (Typeable a) => a -> Maybe CanShow

Implementing such datatypes for needed classes would allow to do some
kind of class casting.

Is it possible to implement this somehow?
Is it a limitation of the implementation or a principal one?


Regards, Teodor.

More information about the Haskell-Cafe mailing list