Consider the following data model utilizing an existential:
data Node a = Node a (Map TypeRep AnyNode)
data AnyNode = forall a. Show a => AnyNode a
The rules about memory footprint of standard types have been explained previously. Now, what are the rules for existential types, like AnyNode
?
Are there any optimization techniques, e.g. some workarounds using unsafeCoerce
making it possible to elude the existential declaration? I'm asking this because a type similar to Node
is going to be placed in a cost centre of a highly memory-intensive lib, so memory footprint is all, that's why the most dirty hacks are welcome.