Hi all. I'm wrestling with a typing problem, which I keep hoping that
I ought to be able to solve with existentially quantified data types,
but such a problem keeps eluding me, leading me to rend my hair at the
prospect of instead having to use a some sort of dynamic type or
universal type hack. (Ick.)
The basic idea is that I want to be able to (for example): generate
an existentially quantified list of some type 't', given a function
(presumably itself in a existential quantifion wrapper of some sort)
return a 't'; sort such an existentially quantified list (or other data
structure); and other such fun stuff.
I can see a problem in the latter case, in that the natural type for
such a sort doesn't work (the E-bound type 'escapes'), and don't
immediately see a way that it can be 'rewrapped' in type correct
manner. Any pointers on how to do this? I'm not clear if this
a) impossible to do with existential types, full stop, not possible
with this particular scheme, or simply requires a different work-
around than I've been using. (This part isn't necessarily vital,
as it may be satisfactory to have a monotyped result.)
The first part mystifies me, though: I can't get the 'existential
map' to work, don't see why it doesn't/shouldn't, don't understand the
sorts of error message I've been getting, and AFAICS, being able to
do this sort of thing seems crucial for me to do anything at all
useful with these things.
Sorry for the vague and dufferish nature of the inquiry; I shall
furnish simple examples of (non-working) code as required (and/or as I
get them off another machine).
Cheers,
Alex.