I am reading the source code for distributed-process and related packages. In distributed-static we have a definition of StaticLabel :
data StaticLabel = StaticLabel String | StaticApply !StaticLabel !StaticLabel | StaticPtr SDynamic deriving (Eq, Ord, Typeable, Show)
which is then used to define Static as newtype wrappers around StaticLabel with a phantom variable attached to a security type:
newtype Static a = Static StaticLabel deriving (Eq, Ord, Typeable, Show)
I have no questions about StaticApply , it just thickens two static values. However, StaticLabel and StaticPtr seem to achieve the same goal in different ways.
If we go with StaticLabel , we just have a / transimt a String label, which can then be used to find the Dynamic value from RemoteTable :
newtype RemoteTable = RemoteTable (Map String Dynamic)
Where Dynamic (defined in rank1dynamic ):
data Dynamic = Dynamic TypeRep GHC.Any
This is almost the same as SDynamic contained in StaticPtr :
data SDynamic = SDynamic TypeRep (StaticPtr GHC.Any)
The difference is that Dynamic has GHC.Any without indirection, with SDynamic we have to look for value. The result is the same: we get that Any value we can unsafeCoerce , if the TypeRep target is equal to instanceOf of the TypeRep we store in SDynamic or Dynamic .
Remote table management, although automated to some degree through TH, is still annoying, so why not use only StaticPtr s? Does StaticLabel exist only for backward compatibility with older GHCs, or am I missing something?