attenuation-0.2.0: Representational subtyping relations and variance roles.
Safe HaskellNone



Unsafe misuses of Attenuations' underlying Coercions.

This can allow violating the invariants of the source type, since it allows casting in the opposite direction from the intended Attenuation. If the Coercion is lifted to a Coercible instance, this is especially bad, since it can get used invisibly to allow lifted or composed coercions that shouldn't be allowed. The contract defined here is that types may rely absolutely on Attenuations not being used backwards in a way that violates their internal invariants, including for type-safety and memory-safety purposes. As such, it is unsafe to extract the Coercion from an Attenuation, and any nonsense that results from doing so constitutes a bug in the client code that called unsafeToCoercion.

This means extreme caution must be used with the contents of this module. It's always safe to use this to cast values back to their original type or to any type the original type is attenuable to. Otherwise, the safety of a particular backwards cast depends entirely on the specific types involved.

Take care not to hold onto / leak inverted Attenuations or illegitimately-obtained Coercions by accident!



unsafeToCoercion :: Attenuation a b -> Coercion a b Source #

Unsafely access the internal Coercion of an Attenuation.

unsafeSym :: Attenuation a b -> Attenuation b a Source #

Unsafely invert an Attenuation.