A question about dynamic typing

Nick Name nick.name@inwind.it
Sat, 18 Jan 2003 14:39:21 +0100


Or maybe the subject has nothing to do with my question :)

I was thinking of an "haskell desktop interface", i.e. just a desktop
interface, but written in haskell.

I thought this: one can define a type class with the "view" method:

data Draw -- the drawing monad

class Visible t where
	view :: t -> Time -> Draw

And so one can have a list of viewable objects and by mapping some
"runDrawIntoIO" function wich spawns a thread for each element of a
list, obtain animated icons and applets where one expects just icons.

If I use the "Visible" class, I can use existential types to create a
non-homogeneous list and "view" all the objects.

The same thing could be achieved, of course, with record types:

data Visible = { view :: Time -> Draw }

and I can achieve the same result I get with existential types.

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.

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