This repository was archived by the owner on Sep 3, 2024. It is now read-only.
Tags: haskell-distributed/distributed-static
Tags
Remove dynamic type check in Static Binary instance. Currently, a dynamic type check occurs when a static value is deserialized. The reason for this check is to preclude writing pathological functions such as `decode . encode` that make it possible to modify the phantom type parameter of the static value. However, `decode . encode` is arguably the same pattern as `read . show`, which in general is unsafe (e.g. whenever phantom type parameters are involved) but not in any manner specific to static values. It is debatable whether we should defensively protect against the user writing such code through the use of extra Typeable constraints. For what is good for the goose is good for the gander, i.e. not just static values, yet we cannot hope to guarantee type safety whenever the representation of an abstract type is exported in any way. Moreover, this dynamic type check is redundant with a second type check that occurs when resolving static values, in 'unstatic'. One can construct all manner of static values and compose them, but they can only be used by resolving them. Hence a dynamic type check will occur at least once, i.e. at resolution time. There is, therefore, little value in doing a dynamic type check earlier, while each such type check has a non negligible performance cost.
PreviousNext