Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.Type.Attenuation.Unsafe
Description
Unsafe misuses of Attenuation
s' underlying Coercion
s.
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 Attenuation
s 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 Attenuation
s or
illegitimately-obtained Coercion
s by accident!
Synopsis
- unsafeToCoercion :: Attenuation a b -> Coercion a b
- unsafeSym :: Attenuation a b -> Attenuation b a
Documentation
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
.