strongweak-0.3.1: Convert between strong and weak representations of types
Safe HaskellSafe-Inferred
LanguageHaskell2010

Strongweak.Strengthen.Unsafe

Synopsis

Documentation

class Weaken a => UnsafeStrengthen a where Source #

Unsafely transform a Weaken a to an a, without asserting invariants.

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 (sized vectors will probably do this).

Only consider using this if you have a guarantee that your value is safe to treat as strong.

Instances should either handle an invariant, or decompose. See Strongweak for a discussion on this design.

Methods

unsafeStrengthen :: Weak a -> a Source #

Unsafely transform a weak value to its associated strong one.

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 a => UnsafeStrengthen (Identity a) Source #

Decomposer.

Instance details

Defined in Strongweak.Strengthen.Unsafe

UnsafeStrengthen (NonEmpty a) Source #

Unsafely assume a list is non-empty.

Instance details

Defined in Strongweak.Strengthen.Unsafe

UnsafeStrengthen a => UnsafeStrengthen (Maybe a) Source #

Decomposer.

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.

Instance details

Defined in Strongweak.Strengthen.Unsafe

Methods

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

UnsafeStrengthen (Vector n a) Source #

Unsafely assume the size of a plain list.

Instance details

Defined in Strongweak.Strengthen.Unsafe

Methods

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

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

Decomposer.

Instance details

Defined in Strongweak.Strengthen.Unsafe

Methods

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

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

Decomposer.

Instance details

Defined in Strongweak.Strengthen.Unsafe

Methods

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

UnsafeStrengthen (Refined p a) Source #

Wrap a value to a refined one without checking the predicate.

Instance details

Defined in Strongweak.Strengthen.Unsafe

Methods

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