| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Refined.Extras.Utils
Description
Utilities for Refined.
Since: 0.1.0.0
Synopsis
- pattern MkRefined :: forall {k} a p. a -> Refined p a
- showRefineException :: RefineException -> String
- showtRefineException :: RefineException -> Text
- refineExceptionToType :: RefineException -> TypeRep
Pattern Synonym
pattern MkRefined :: forall {k} a p. a -> Refined p a Source #
Unidirectional pattern synonym for Refined. This allows us to pattern
match on a refined term without exposing the unsafe internal details.
Examples
>>>:{let safeDiv :: Implies p NonZero => Int -> Refined p Int -> Int safeDiv n (MkRefined d) = n `div` d two = $$(refineTH @NonZero @Int 2) in safeDiv 10 two :} 5
Since: 0.1.0.0
Exception Functions
showRefineException :: RefineException -> String Source #
Displays a RefineException without formatting. Intended for situations
where RefineException's default formatting is undesirable
(e.g. doctests, logging).
Examples
>>>first showRefineException $ refine @(And NonZero NonNegative) 0Left "RefineAndException (And * * (NotEqualTo 0) (From 0)) (This (RefineOtherException (NotEqualTo 0) \"Value does equal 0\"))"
>>>let ex = refine @(Xor (And NonZero NonNegative) NonZero) 0>>>first showRefineException exLeft "RefineXorException (Xor * * (And * * (NotEqualTo 0) (From 0)) (NotEqualTo 0)) (RefineAndException (And * * (NotEqualTo 0) (From 0)) (This (RefineOtherException (NotEqualTo 0) \"Value does equal 0\"))) (RefineOtherException (NotEqualTo 0) \"Value does equal 0\")"
Since: 0.1.0.0
showtRefineException :: RefineException -> Text Source #
Variant of showRefineException for Text.
Since: 0.1.0.0
refineExceptionToType :: RefineException -> TypeRep Source #
Retrieves the TypeRep corresponding to a RefineException.
Examples
>>>first refineExceptionToType $ refine @(And NonZero NonNegative) 0Left (And * * (NotEqualTo 0) (From 0))
Since: 0.1.0.0