Safe Haskell | None |
---|---|
Language | GHC2024 |
Extension.Refined
Synopsis
- pattern Refined :: forall {k} x p. x -> Refined p x
- rerefine :: forall {k} (p :: k) x. Predicate p x => (x -> x) -> Refined p x -> Either RefineException (Refined p x)
- parseSomeException :: RefineException -> Maybe SomeException
- data Refined (p :: k) x
- class Typeable p => Predicate (p :: k) x where
- validate :: Proxy p -> x -> Maybe RefineException
- data RefineException
- = RefineNotException !TypeRep
- | RefineAndException !TypeRep !(These RefineException RefineException)
- | RefineOrException !TypeRep !RefineException !RefineException
- | RefineXorException !TypeRep !(Maybe (RefineException, RefineException))
- | RefineSomeException !TypeRep !SomeException
- | RefineOtherException !TypeRep !Text
- data FromTo (mn :: Nat) (mx :: Nat) = FromTo
- type (&&) = And :: k -> k1 -> Type
- refine :: forall {k} (p :: k) x. Predicate p x => x -> Either RefineException (Refined p x)
- unrefine :: forall {k} (p :: k) x. Refined p x -> x
- success :: Maybe RefineException
- throwRefineSomeException :: TypeRep -> SomeException -> Maybe RefineException
Documentation
rerefine :: forall {k} (p :: k) x. Predicate p x => (x -> x) -> Refined p x -> Either RefineException (Refined p x) #
A refinement type, which wraps a value of type x
.
Since: refined-0.1.0.0
Instances
KnownNat sc => Predicate NotEmpty (Set (Proposal sc)) # | |
Defined in Aggregate.Proposal | |
KnownNat sc => Predicate (BoundedSeatNumber sc :: Type) (Bimap Passenger Seat) # | |
Defined in Aggregate.Assignment Methods validate :: Proxy (BoundedSeatNumber sc) -> Bimap Passenger Seat -> Maybe RefineException # | |
Lift x => Lift (Refined p x :: Type) | Since: refined-0.1.0.0 |
Foldable (Refined p) | Since: refined-0.2 |
Defined in Refined.Unsafe.Type Methods fold :: Monoid m => Refined p m -> m # foldMap :: Monoid m => (a -> m) -> Refined p a -> m # foldMap' :: Monoid m => (a -> m) -> Refined p a -> m # foldr :: (a -> b -> b) -> b -> Refined p a -> b # foldr' :: (a -> b -> b) -> b -> Refined p a -> b # foldl :: (b -> a -> b) -> b -> Refined p a -> b # foldl' :: (b -> a -> b) -> b -> Refined p a -> b # foldr1 :: (a -> a -> a) -> Refined p a -> a # foldl1 :: (a -> a -> a) -> Refined p a -> a # toList :: Refined p a -> [a] # length :: Refined p a -> Int # elem :: Eq a => a -> Refined p a -> Bool # maximum :: Ord a => Refined p a -> a # minimum :: Ord a => Refined p a -> a # | |
NFData x => NFData (Refined p x) | Since: refined-0.5 |
Defined in Refined.Unsafe.Type | |
Show x => Show (Refined p x) | Since: refined-0.1.0.0 |
Eq x => Eq (Refined p x) | Since: refined-0.1.0.0 |
Ord x => Ord (Refined p x) | Since: refined-0.1.0.0 |
Defined in Refined.Unsafe.Type | |
Hashable x => Hashable (Refined p x) | Since: refined-0.6.3 |
Defined in Refined.Unsafe.Type |
class Typeable p => Predicate (p :: k) x where #
A typeclass which defines a runtime interpretation of
a type-level predicate p
for type x
.
Since: refined-0.1.0.0
Methods
validate :: Proxy p -> x -> Maybe RefineException #
Check the value x
according to the predicate p
,
producing an error RefineException
if the value
does not satisfy.
Note: validate
is not intended to be used
directly; instead, it is intended to provide the minimal
means necessary for other utilities to be derived. As
such, the Maybe
here should be interpreted to mean
the presence or absence of a RefineException
, and
nothing else.
Instances
data RefineException #
An exception encoding the way in which a Predicate
failed.
Since: refined-0.2.0.0
Constructors
RefineNotException !TypeRep | A Since: refined-0.2.0.0 |
RefineAndException !TypeRep !(These RefineException RefineException) | A Since: refined-0.2.0.0 |
RefineOrException !TypeRep !RefineException !RefineException | A Since: refined-0.2.0.0 |
RefineXorException !TypeRep !(Maybe (RefineException, RefineException)) | A Since: refined-0.5 |
RefineSomeException !TypeRep !SomeException | A Since: refined-0.5 |
RefineOtherException !TypeRep !Text | A Since: refined-0.2.0.0 |
Instances
data FromTo (mn :: Nat) (mx :: Nat) #
A Predicate
ensuring that the value is within an inclusive range.
>>>
isRight (refine @(FromTo 0 16) @Int 13)
True
>>>
isRight (refine @(FromTo 13 15) @Int 13)
True
>>>
isRight (refine @(FromTo 13 15) @Int 15)
True
>>>
isLeft (refine @(FromTo 13 15) @Int 12)
True
Since: refined-0.1.2
Constructors
FromTo | Since: refined-0.4.2 |
Instances
KnownNat sc => Predicate NotEmpty (Set (Proposal sc)) # | |
Defined in Aggregate.Proposal | |
p <= n => Weaken (FromTo n m :: Type) (From p :: Type) | Since: refined-0.2.0.0 |
m <= q => Weaken (FromTo n m :: Type) (To q :: Type) | Since: refined-0.2.0.0 |
(p <= n, m <= q) => Weaken (FromTo n m :: Type) (FromTo p q :: Type) | Since: refined-0.2.0.0 |
KnownNat sc => Predicate (BoundedSeatNumber sc :: Type) (Bimap Passenger Seat) # | |
Defined in Aggregate.Assignment Methods validate :: Proxy (BoundedSeatNumber sc) -> Bimap Passenger Seat -> Maybe RefineException # | |
(Ord x, Num x, KnownNat mn, KnownNat mx, mn <= mx) => Predicate (FromTo mn mx :: Type) x | Since: refined-0.1.2 |
Generic (FromTo mn mx) | |
type Rep (FromTo mn mx) | Since: refined-0.3.0.0 |
type (&&) = And :: k -> k1 -> Type infixr 3 #
The conjunction of two predicates.
Since: refined-0.2.0.0
refine :: forall {k} (p :: k) x. Predicate p x => x -> Either RefineException (Refined p x) #
A smart constructor of a Refined
value.
Checks the input value at runtime.
Since: refined-0.1.0.0
unrefine :: forall {k} (p :: k) x. Refined p x -> x #
Extracts the refined value.
Since: refined-0.1.0.0
Arguments
:: TypeRep | The |
-> SomeException | A custom exception. |
-> Maybe RefineException |
A handler for a
.RefineException
throwRefineSomeException
is useful for defining what
behaviour validate
should have in the event of a predicate failure
with a specific exception.
Since: refined-0.5