Safe Haskell | None |
---|---|
Language | GHC2021 |
Strongweak.Strengthen.Unsafe
Synopsis
- class Weaken a => UnsafeStrengthen a where
- unsafeStrengthen :: Weakened a -> a
Documentation
class Weaken a => UnsafeStrengthen a where Source #
Unsafely transform a
to an Weakened
aa
, without asserting invariants.
Naturally, you must only even consider using this if you have a guarantee that your value is safe to treat as strong.
For example, you may unsafely strengthen some
into
a Natural
nWord8
by unsafely coercing the value, ignoring the possibility that n >=
255
.
What happens if it turns out you're lying to the computer and your weak value doesn't fit in its strong counterpart? That depends on the strengthen.
- Numeric coercions should safely overflow.
- Some will raise an error (e.g.
NonEmpty
). - Others will appear to work, but later explode your computer.
See Strongweak for class design notes and laws.
Methods
unsafeStrengthen :: Weakened a -> a Source #
Unsafely transform a
to its associated strong type Weakened
aa
.