Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- class Weaken a => UnsafeStrengthen a where
- unsafeStrengthen :: Weak a -> a
Documentation
class Weaken a => UnsafeStrengthen a where Source #
Unsafely transform a
to an Weaken
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.
unsafeStrengthen :: Weak a -> a Source #
Unsafely transform a
to its associated strong type Weaken
aa
.