strongweak-0.6.0: Convert between strong and weak representations of types
Safe HaskellSafe-Inferred
LanguageGHC2021

Strongweak.Strengthen.Unsafe

Synopsis

Documentation

class Weaken a => UnsafeStrengthen a where Source #

Unsafely transform a Weaken a to an a, 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 Natural n into a Word8 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 :: Weak a -> a Source #

Unsafely transform a Weaken a to its associated strong type a.

Instances

Instances details
UnsafeStrengthen Int16 Source # 
Instance details

Defined in Strongweak.Strengthen.Unsafe

UnsafeStrengthen Int32 Source # 
Instance details

Defined in Strongweak.Strengthen.Unsafe

UnsafeStrengthen Int64 Source # 
Instance details

Defined in Strongweak.Strengthen.Unsafe

UnsafeStrengthen Int8 Source # 
Instance details

Defined in Strongweak.Strengthen.Unsafe

UnsafeStrengthen Word16 Source # 
Instance details

Defined in Strongweak.Strengthen.Unsafe

UnsafeStrengthen Word32 Source # 
Instance details

Defined in Strongweak.Strengthen.Unsafe

UnsafeStrengthen Word64 Source # 
Instance details

Defined in Strongweak.Strengthen.Unsafe

UnsafeStrengthen Word8 Source # 
Instance details

Defined in Strongweak.Strengthen.Unsafe

UnsafeStrengthen (Identity a) Source #

Add wrapper.

Instance details

Defined in Strongweak.Strengthen.Unsafe

UnsafeStrengthen (NonEmpty a) Source #

Assume a plain list is non-empty.

Instance details

Defined in Strongweak.Strengthen.Unsafe

UnsafeStrengthen a => UnsafeStrengthen [a] Source #

Decomposer. Unsafely strengthen every element in a list.

Instance details

Defined in Strongweak.Strengthen.Unsafe

Methods

unsafeStrengthen :: Weak [a] -> [a] Source #

(UnsafeStrengthen a, UnsafeStrengthen b) => UnsafeStrengthen (Either a b) Source #

Decomposer. Unsafely strengthen either side of an Either.

Instance details

Defined in Strongweak.Strengthen.Unsafe

Methods

unsafeStrengthen :: Weak (Either a b) -> Either a b Source #

(UnsafeStrengthen a, UnsafeStrengthen b) => UnsafeStrengthen (a, b) Source #

Decomposer. Unsafely strengthen both elements of a tuple.

Instance details

Defined in Strongweak.Strengthen.Unsafe

Methods

unsafeStrengthen :: Weak (a, b) -> (a, b) Source #

UnsafeStrengthen (Const a b) Source #

Add wrapper.

Instance details

Defined in Strongweak.Strengthen.Unsafe

Methods

unsafeStrengthen :: Weak (Const a b) -> Const a b Source #

UnsafeStrengthen (Refined p a) Source #

Add a refinement to a type without checking the associated predicate.

Instance details

Defined in Strongweak.Strengthen.Unsafe

Methods

unsafeStrengthen :: Weak (Refined p a) -> Refined p a Source #

Vector v a => UnsafeStrengthen (Vector v n a) Source #

Assume the size of a plain list.

Instance details

Defined in Strongweak.Strengthen.Unsafe

Methods

unsafeStrengthen :: Weak (Vector v n a) -> Vector v n a Source #