refined-extras-0.1.0.0: Increased functionality for refined types.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Refined.Extras.Unsafe

Description

Exports unsafe functions.

Since: 0.1.0.0

Synopsis

Documentation

unsafeLiftR :: (HasCallStack, Predicate p b) => (a -> b) -> Refined p a -> Refined p b Source #

Lifts a function onto Refined, dying with an error if the predicate is not preserved. Intended for when we know a function preserves the refinement (e.g. addition of positive integers).

WARNING: This function is not total. Exercise restraint!

Examples

Expand
>>> unsafeLiftR (fmap even) $$(refineTH @(SizeEqualTo 4) [2, 4, 1, 8])
Refined [True,True,False,True]

Since: 0.1.0.0

unsafeLiftR2 :: (HasCallStack, Predicate p c) => (a -> b -> c) -> Refined p a -> Refined p b -> Refined p c Source #

Lifts a binary function onto Refined, dying with an error if the predicate is not preserved. Intended for when we know a function preserves the refinement (e.g. addition of positive integers).

WARNING: This function is not total. Exercise restraint!

Examples

Expand
>>> unsafeLiftR2 (+) $$(refineTH @Positive 7) $$(refineTH @Positive 11)
Refined 18

Since: 0.1.0.0

unsafeLiftR3 :: (HasCallStack, Predicate p d) => (a -> b -> c -> d) -> Refined p a -> Refined p b -> Refined p c -> Refined p d Source #

Lifts a ternary function onto Refined, dying with an error if the predicate is not preserved. Intended for when we know a function preserves the refinement (e.g. addition of positive integers).

WARNING: This function is not total. Exercise restraint!

Examples

Expand
>>> unsafeLiftR3 (\x y z -> x + y + z) $$(refineTH @Positive 1) $$(refineTH @Positive 2) $$(refineTH @Positive 3)
Refined 6

Since: 0.1.0.0