
Nick Name
Or maybe the subject has nothing to do with my question :)
It does, I think. <snip subject="class Visible"/>
My problem is: an user putting someway different "visible" elements in a list (wich could be represented in a side panel) will want to retrieve an object with its full type when clicking on it (to be able to perform specific applications), but this isn't allowed by the type system.
This does require dynamic, run-time typing (to make the cast safe). GHC has a dynamic typing library (for monomorphic types only, but I doubt that'll be an issue for you); it's in Data.Dynamic. Short version: if Typeable is a super-class of Visible or mentioned in your existential type (i.e., forall a. (Visible a, Typeable a) => Con) you can use (fromDynamic . toDyn) to safely (attempt to) convert the abstract type into the concrete one. If that last paragraph wasn't coherent, I can try to explain it more.
It's not a problem of functional programming: even in object oriented programming I see the same problem if one doesn't use some form of typecast.
Where am I wrong? Are there alternatives?
Vincenzo
Jon Cast