Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Refined3 (opts :: OptT) ip op fmt i
- type Refined3C opts ip op fmt i = (OptTC opts, P ip i, P op (PP ip i), PP op (PP ip i) ~ Bool, P fmt (PP ip i), PP fmt (PP ip i) ~ i)
- prtEval3 :: forall opts ip op fmt i. (Refined3C opts ip op fmt i, Show (PP ip i), Show i) => i -> Either Msg3 (Refined3 opts ip op fmt i)
- prtEval3P :: forall opts ip op fmt i proxy. (Refined3C opts ip op fmt i, Show (PP ip i), Show i) => proxy '(opts, ip, op, fmt, i) -> i -> Either Msg3 (Refined3 opts ip op fmt i)
- prtEval3IO :: forall opts ip op fmt i. (Refined3C opts ip op fmt i, Show (PP ip i), Show i) => i -> IO (Either String (Refined3 opts ip op fmt i))
- prtEval3PIO :: forall opts ip op fmt i proxy. (Refined3C opts ip op fmt i, Show (PP ip i), Show i) => proxy '(opts, ip, op, fmt, i) -> i -> IO (Either String (Refined3 opts ip op fmt i))
- prt3IO :: forall opts a b r. (OptTC opts, Show a, Show b) => (RResults3 a b, Maybe r) -> IO (Either String r)
- prt3Impl :: forall a b. (Show a, Show b) => POpts -> RResults3 a b -> Msg3
- data Msg3 = Msg3 {}
- data RResults3 a b
- eval3 :: forall opts ip op fmt i. Refined3C opts ip op fmt i => i -> (RResults3 (PP ip i) (PP fmt (PP ip i)), Maybe (Refined3 opts ip op fmt i))
- eval3P :: forall opts ip op fmt i proxy. Refined3C opts ip op fmt i => proxy '(opts, ip, op, fmt, i) -> i -> (RResults3 (PP ip i) (PP fmt (PP ip i)), Maybe (Refined3 opts ip op fmt i))
- eval3M :: forall opts ip op fmt i m. (MonadEval m, Refined3C opts ip op fmt i) => i -> m (RResults3 (PP ip i) (PP fmt (PP ip i)), Maybe (Refined3 opts ip op fmt i))
- newRefined3 :: forall opts ip op fmt i. (Refined3C opts ip op fmt i, Show (PP ip i), Show i) => i -> Either String (Refined3 opts ip op fmt i)
- newRefined3P :: forall opts ip op fmt i proxy. (Refined3C opts ip op fmt i, Show (PP ip i), Show i) => proxy '(opts, ip, op, fmt, i) -> i -> Either String (Refined3 opts ip op fmt i)
- newRefined3T :: forall opts ip op fmt i m. (Refined3C opts ip op fmt i, Monad m, Show (PP ip i), Show i) => i -> RefinedT m (Refined3 opts ip op fmt i)
- newRefined3TP :: forall opts ip op fmt i proxy m. (Refined3C opts ip op fmt i, Monad m, Show (PP ip i), Show i) => proxy '(opts, ip, op, fmt, i) -> i -> RefinedT m (Refined3 opts ip op fmt i)
- newRefined3TPIO :: forall opts ip op fmt i proxy m. (Refined3C opts ip op fmt i, MonadIO m, Show (PP ip i), Show i) => proxy '(opts, ip, op, fmt, i) -> i -> RefinedT m (Refined3 opts ip op fmt i)
- newRefined3TIO :: forall opts ip op fmt i m. (Refined3C opts ip op fmt i, MonadIO m, Show (PP ip i), Show i) => i -> RefinedT m (Refined3 opts ip op fmt i)
- withRefined3T :: forall opts ip op fmt i m b. (Monad m, Refined3C opts ip op fmt i, Show (PP ip i), Show i) => i -> (Refined3 opts ip op fmt i -> RefinedT m b) -> RefinedT m b
- withRefined3TIO :: forall opts ip op fmt i m b. (MonadIO m, Refined3C opts ip op fmt i, Show (PP ip i), Show i) => i -> (Refined3 opts ip op fmt i -> RefinedT m b) -> RefinedT m b
- withRefined3TP :: forall opts ip op fmt i b proxy m. (Monad m, Refined3C opts ip op fmt i, Show (PP ip i), Show i) => proxy '(opts, ip, op, fmt, i) -> i -> (Refined3 opts ip op fmt i -> RefinedT m b) -> RefinedT m b
- mkProxy3 :: forall z opts ip op fmt i. z ~ '(opts, ip, op, fmt, i) => Proxy '(opts, ip, op, fmt, i)
- mkProxy3' :: forall z opts ip op fmt i. (z ~ '(opts, ip, op, fmt, i), Refined3C opts ip op fmt i) => Proxy '(opts, ip, op, fmt, i)
- type family MakeR3 p where ...
- type family MakeR3' opts p where ...
- unsafeRefined3 :: forall opts ip op fmt i. PP ip i -> PP fmt (PP ip i) -> Refined3 opts ip op fmt i
- unsafeRefined3' :: forall opts ip op fmt i. (HasCallStack, Show i, Show (PP ip i), Refined3C opts ip op fmt i) => i -> Refined3 opts ip op fmt i
- convertRefined3TP :: forall opts ip op fmt i ip1 op1 fmt1 i1 m. (Refined3C opts ip op fmt i, Refined3C opts ip1 op1 fmt1 i1, Monad m, Show (PP ip i), PP ip i ~ PP ip1 i1, Show i1) => Proxy '(opts, ip, op, fmt, i) -> Proxy '(opts, ip1, op1, fmt1, i1) -> RefinedT m (Refined3 opts ip op fmt i) -> RefinedT m (Refined3 opts ip1 op1 fmt1 i1)
- rapply3 :: forall opts ip op fmt i m. (Refined3C opts ip op fmt i, Monad m, Show (PP ip i), Show i) => (PP ip i -> PP ip i -> PP ip i) -> RefinedT m (Refined3 opts ip op fmt i) -> RefinedT m (Refined3 opts ip op fmt i) -> RefinedT m (Refined3 opts ip op fmt i)
- rapply3P :: forall opts ip op fmt i proxy m. (Refined3C opts ip op fmt i, Monad m, Show (PP ip i), Show i) => proxy '(opts, ip, op, fmt, i) -> (PP ip i -> PP ip i -> PP ip i) -> RefinedT m (Refined3 opts ip op fmt i) -> RefinedT m (Refined3 opts ip op fmt i) -> RefinedT m (Refined3 opts ip op fmt i)
- genRefined3 :: forall opts ip op fmt i. Refined3C opts ip op fmt i => Gen (PP ip i) -> Gen (Refined3 opts ip op fmt i)
- genRefined3P :: forall opts ip op fmt i. Refined3C opts ip op fmt i => Proxy '(opts, ip, op, fmt, i) -> Gen (PP ip i) -> Gen (Refined3 opts ip op fmt i)
- type RefinedEmulate (opts :: OptT) p a = Refined3 opts Id p Id a
- eval3PX :: forall opts ip op fmt i proxy. Refined3C opts ip op fmt i => proxy '(opts, ip, op, fmt, i) -> i -> (RResults3 (PP ip i) (PP fmt (PP ip i)), Maybe (Refined opts op (PP ip i), PP fmt (PP ip i)))
- eval3X :: forall opts ip op fmt i. Refined3C opts ip op fmt i => i -> (RResults3 (PP ip i) (PP fmt (PP ip i)), Maybe (Refined opts op (PP ip i), PP fmt (PP ip i)))
- type family ReplaceOptT3 (o :: OptT) t where ...
- type family AppendOptT3 (o :: OptT) t where ...
Refined3
data Refined3 (opts :: OptT) ip op fmt i Source #
Like Refined2
but additionally reconstructs the output value to a standardized format
opts
are the display optionsip
convertsi
toPP ip i
which is the internal type and stored inr3In
op
validates that internal type usingPP op (PP ip i) ~ Bool
fmt
outputs the internal typePP fmt (PP ip i) ~ i
and stored inr3Out
i
is the input typePP fmt (PP ip i)
should be valid as input for Refined3
Setting ip
to Id
and fmt
to Id
is equivalent to Refined
: see RefinedEmulate
Setting the input type i
to String
resembles the corresponding Read/Show instances but with an additional predicate on the read value
- read a string using ip into an internal type and store in
r3In
- validate
r3In
using the predicate op - show
r3In
using fmt and store that formatted result inr3Out
Although a common scenario is String as input, you are free to choose any input type you like
>>>
newRefined3 @OZ @(ReadBase Int 16 Id) @(Lt 255) @(PrintF "%x" Id) "00fe"
Right (Refined3 {r3In = 254, r3Out = "fe"})
>>>
newRefined3 @OZ @(ReadBase Int 16 Id) @(Lt 253) @(PrintF "%x" Id) "00fe"
Left "Step 2. False Boolean Check(op) | FalseP"
>>>
newRefined3 @OZ @(ReadBase Int 16 Id) @(Lt 255) @(PrintF "%x" Id) "00fg"
Left "Step 1. Initial Conversion(ip) Failed | invalid base 16"
>>>
newRefined3 @OL @(Map (ReadP Int Id) (Resplit "\\." Id)) @(Msg "length invalid:" (Len == 4)) @(PrintL 4 "%03d.%03d.%03d.%03d" Id) "198.162.3.1.5"
Left "Step 2. False Boolean Check(op) | {length invalid: 5 == 4}"
>>>
newRefined3 @OZ @(Map (ReadP Int Id) (Resplit "\\." Id)) @(Guard (PrintF "found length=%d" Len) (Len == 4) >> 'True) @(PrintL 4 "%03d.%03d.%03d.%03d" Id) "198.162.3.1.5"
Left "Step 2. Failed Boolean Check(op) | found length=5"
>>>
newRefined3 @OZ @(Map (ReadP Int Id) (Resplit "\\." Id)) @(Guard (PrintF "found length=%d" Len) (Len == 4) >> 'True) @(PrintL 4 "%03d.%03d.%03d.%03d" Id) "198.162.3.1"
Right (Refined3 {r3In = [198,162,3,1], r3Out = "198.162.003.001"})
>>>
:m + Data.Time.Calendar.WeekDate
>>>
newRefined3 @OZ @(MkDayExtra Id >> 'Just Id) @(Guard "expected a Sunday" (Thd Id == 7) >> 'True) @(UnMkDay (Fst Id)) (2019,10,13)
Right (Refined3 {r3In = (2019-10-13,41,7), r3Out = (2019,10,13)})
>>>
newRefined3 @OL @(MkDayExtra Id >> 'Just Id) @(Msg "expected a Sunday:" (Thd Id == 7)) @(UnMkDay (Fst Id)) (2019,10,12)
Left "Step 2. False Boolean Check(op) | {expected a Sunday: 6 == 7}"
>>>
newRefined3 @OZ @(MkDayExtra' (Fst Id) (Snd Id) (Thd Id) >> 'Just Id) @(Guard "expected a Sunday" (Thd Id == 7) >> 'True) @(UnMkDay (Fst Id)) (2019,10,12)
Left "Step 2. Failed Boolean Check(op) | expected a Sunday"
>>>
type T4 k = '( OZ, MkDayExtra Id >> 'Just Id, Guard "expected a Sunday" (Thd Id == 7) >> 'True, UnMkDay (Fst Id), k)
>>>
newRefined3P (Proxy @(T4 _)) (2019,10,12)
Left "Step 2. Failed Boolean Check(op) | expected a Sunday"
>>>
newRefined3P (Proxy @(T4 _)) (2019,10,13)
Right (Refined3 {r3In = (2019-10-13,41,7), r3Out = (2019,10,13)})
Instances
(Eq i, Eq (PP ip i), Eq (PP fmt (PP ip i))) => Eq (Refined3 opts ip op fmt i) Source # | |
(Eq i, Show i, Show (PP ip i), Refined3C opts ip op fmt i, Read (PP ip i), Read (PP fmt (PP ip i))) => Read (Refined3 opts ip op fmt i) Source # |
|
(Show i, Show (PP ip i), Show (PP fmt (PP ip i))) => Show (Refined3 opts ip op fmt i) Source # | |
(Refined3C opts ip op fmt String, Show (PP ip String)) => IsString (Refined3 opts ip op fmt String) Source # |
|
Defined in Predicate.Refined3 fromString :: String -> Refined3 opts ip op fmt String # | |
(Lift (PP ip i), Lift (PP fmt (PP ip i))) => Lift (Refined3 opts ip op fmt i) Source # | |
(Arbitrary (PP ip i), Refined3C opts ip op fmt i) => Arbitrary (Refined3 opts ip op fmt i) Source # |
|
(Refined3C opts ip op fmt i, Hashable (PP ip i)) => Hashable (Refined3 opts ip op fmt i) Source # | |
Defined in Predicate.Refined3 | |
ToJSON (PP fmt (PP ip i)) => ToJSON (Refined3 opts ip op fmt i) Source # |
|
Defined in Predicate.Refined3 | |
(Show (PP fmt (PP ip i)), Show (PP ip i), Refined3C opts ip op fmt i, FromJSON i) => FromJSON (Refined3 opts ip op fmt i) Source # |
|
(Show (PP fmt (PP ip i)), Show (PP ip i), Refined3C opts ip op fmt i, Binary i) => Binary (Refined3 opts ip op fmt i) Source # |
|
type Refined3C opts ip op fmt i = (OptTC opts, P ip i, P op (PP ip i), PP op (PP ip i) ~ Bool, P fmt (PP ip i), PP fmt (PP ip i) ~ i) Source #
Provides the constraints on Refined3
display results
prtEval3 :: forall opts ip op fmt i. (Refined3C opts ip op fmt i, Show (PP ip i), Show i) => i -> Either Msg3 (Refined3 opts ip op fmt i) Source #
same as prtEval3P
but skips the proxy and allows you to set each parameter individually using type application
prtEval3P :: forall opts ip op fmt i proxy. (Refined3C opts ip op fmt i, Show (PP ip i), Show i) => proxy '(opts, ip, op, fmt, i) -> i -> Either Msg3 (Refined3 opts ip op fmt i) Source #
create a Refined3 using a 5-tuple proxy and aggregate the results on failure
prtEval3IO :: forall opts ip op fmt i. (Refined3C opts ip op fmt i, Show (PP ip i), Show i) => i -> IO (Either String (Refined3 opts ip op fmt i)) Source #
same as prtEval3PIO
but passes in the proxy
prtEval3PIO :: forall opts ip op fmt i proxy. (Refined3C opts ip op fmt i, Show (PP ip i), Show i) => proxy '(opts, ip, op, fmt, i) -> i -> IO (Either String (Refined3 opts ip op fmt i)) Source #
same as prtEval3P
but runs in IO
prt3IO :: forall opts a b r. (OptTC opts, Show a, Show b) => (RResults3 a b, Maybe r) -> IO (Either String r) Source #
An ADT that summarises the results of evaluating Refined3 representing all possible states
evaluation methods
eval3 :: forall opts ip op fmt i. Refined3C opts ip op fmt i => i -> (RResults3 (PP ip i) (PP fmt (PP ip i)), Maybe (Refined3 opts ip op fmt i)) Source #
same as eval3P
but can pass the parameters individually using type application
eval3P :: forall opts ip op fmt i proxy. Refined3C opts ip op fmt i => proxy '(opts, ip, op, fmt, i) -> i -> (RResults3 (PP ip i) (PP fmt (PP ip i)), Maybe (Refined3 opts ip op fmt i)) Source #
eval3M :: forall opts ip op fmt i m. (MonadEval m, Refined3C opts ip op fmt i) => i -> m (RResults3 (PP ip i) (PP fmt (PP ip i)), Maybe (Refined3 opts ip op fmt i)) Source #
newRefined3 :: forall opts ip op fmt i. (Refined3C opts ip op fmt i, Show (PP ip i), Show i) => i -> Either String (Refined3 opts ip op fmt i) Source #
pure version for extracting Refined3
>>>
newRefined3 @OL @(ParseTimeP TimeOfDay "%-H:%-M:%-S" Id) @'True @(FormatTimeP "%H:%M:%S" Id) "1:15:7"
Right (Refined3 {r3In = 01:15:07, r3Out = "01:15:07"})
>>>
newRefined3 @OL @(ParseTimeP TimeOfDay "%-H:%-M:%-S" Id) @'True @(FormatTimeP "%H:%M:%S" Id) "1:2:x"
Left "Step 1. Initial Conversion(ip) Failed | ParseTimeP TimeOfDay (%-H:%-M:%-S) failed to parse"
>>>
newRefined3 @OL @(Rescan "^(\\d{1,2}):(\\d{1,2}):(\\d{1,2})$" Id >> Snd (Head Id) >> Map (ReadP Int Id) Id) @(All (0 <..> 59) Id && Len == 3) @(PrintL 3 "%02d:%02d:%02d" Id) "1:2:3"
Right (Refined3 {r3In = [1,2,3], r3Out = "01:02:03"})
newRefined3P :: forall opts ip op fmt i proxy. (Refined3C opts ip op fmt i, Show (PP ip i), Show i) => proxy '(opts, ip, op, fmt, i) -> i -> Either String (Refined3 opts ip op fmt i) Source #
create a wrapped Refined3 value
newRefined3T :: forall opts ip op fmt i m. (Refined3C opts ip op fmt i, Monad m, Show (PP ip i), Show i) => i -> RefinedT m (Refined3 opts ip op fmt i) Source #
create a wrapped Refined3
type
>>>
prtRefinedTIO $ newRefined3T @OZ @(MkDayExtra Id >> 'Just Id) @(GuardSimple (Thd Id == 5) >> 'True) @(UnMkDay (Fst Id)) (2019,11,1)
Refined3 {r3In = (2019-11-01,44,5), r3Out = (2019,11,1)}
>>>
prtRefinedTIO $ newRefined3T @OL @(MkDayExtra Id >> 'Just Id) @(Thd Id == 5) @(UnMkDay (Fst Id)) (2019,11,2)
failure msg[Step 2. False Boolean Check(op) | {6 == 5}]
>>>
prtRefinedTIO $ newRefined3T @OL @(MkDayExtra Id >> 'Just Id) @(Msg "wrong day:" (Thd Id == 5)) @(UnMkDay (Fst Id)) (2019,11,2)
failure msg[Step 2. False Boolean Check(op) | {wrong day: 6 == 5}]
newRefined3TP :: forall opts ip op fmt i proxy m. (Refined3C opts ip op fmt i, Monad m, Show (PP ip i), Show i) => proxy '(opts, ip, op, fmt, i) -> i -> RefinedT m (Refined3 opts ip op fmt i) Source #
create a wrapped Refined3
type
>>>
prtRefinedTIO $ newRefined3TP (Proxy @'( OZ, MkDayExtra Id >> 'Just Id, GuardSimple (Thd Id == 5) >> 'True, UnMkDay (Fst Id), (Int,Int,Int))) (2019,11,1)
Refined3 {r3In = (2019-11-01,44,5), r3Out = (2019,11,1)}
>>>
prtRefinedTIO $ newRefined3TP (Proxy @'( OL, MkDayExtra Id >> 'Just Id, Thd Id == 5, UnMkDay (Fst Id), (Int,Int,Int))) (2019,11,2)
failure msg[Step 2. False Boolean Check(op) | {6 == 5}]
>>>
prtRefinedTIO $ newRefined3TP (Proxy @'( OL, MkDayExtra Id >> 'Just Id, Msg "wrong day:" (Thd Id == 5), UnMkDay (Fst Id), (Int,Int,Int))) (2019,11,2)
failure msg[Step 2. False Boolean Check(op) | {wrong day: 6 == 5}]
newRefined3TPIO :: forall opts ip op fmt i proxy m. (Refined3C opts ip op fmt i, MonadIO m, Show (PP ip i), Show i) => proxy '(opts, ip, op, fmt, i) -> i -> RefinedT m (Refined3 opts ip op fmt i) Source #
newRefined3TIO :: forall opts ip op fmt i m. (Refined3C opts ip op fmt i, MonadIO m, Show (PP ip i), Show i) => i -> RefinedT m (Refined3 opts ip op fmt i) Source #
wrap a Refined3 type using RefinedT and IO
>>>
prtRefinedTIO $ newRefined3TIO @OL @(Hide (Rescan "(\\d+)" Id >> ConcatMap (Snd Id) Id) >> Map (ReadP Int Id) Id) @(Len > 0 && All (0 <..> 0xff) Id) @(ShowP Id) "|23|99|255|254.911."
failure msg[Step 2. False Boolean Check(op) | {True && False | (All(5) i=4 (911 <= 255))}]
>>>
unRavelT $ newRefined3TIO @OL @(Hide (Rescan "(\\d+)" Id >> ConcatMap (Snd Id) Id) >> Map (ReadP Int Id) Id) @(Len > 0 && All (0 <..> 0xff) Id) @(ShowP Id) "|23|99|255|254.911."
(Left "Step 2. False Boolean Check(op) | {True && False | (All(5) i=4 (911 <= 255))}",[""])
withRefined3T :: forall opts ip op fmt i m b. (Monad m, Refined3C opts ip op fmt i, Show (PP ip i), Show i) => i -> (Refined3 opts ip op fmt i -> RefinedT m b) -> RefinedT m b Source #
create a Refined3
value using a continuation
This first example reads a hex string and makes sure it is between 100 and 200 and then reads a binary string and adds the values together
>>>
:set -XPolyKinds
>>>
:set -XRankNTypes
>>>
b16 :: forall opts . Proxy '( opts, ReadBase Int 16 Id, Between 100 200 Id, ShowBase 16 Id, String); b16 = Proxy
>>>
b2 :: forall opts . Proxy '( opts, ReadBase Int 2 Id, 'True, ShowBase 2 Id, String); b2 = Proxy
>>>
prtRefinedTIO $ withRefined3TP (b16 @OZ) "a3" $ \x -> withRefined3TP (b2 @OZ) "1001110111" $ \y -> pure (r3In x + r3In y)
794
this example fails as the the hex value is out of range
>>>
prtRefinedTIO $ withRefined3TP (b16 @OAN) "a388" $ \x -> withRefined3TP (b2 @OAN) "1001110111" $ \y -> pure (x,y)
*** Step 1. Success Initial Conversion(ip) (41864) *** P ReadBase(Int,16) 41864 | `- P Id "a388" *** Step 2. False Boolean Check(op) *** False 41864 <= 200 | +- P Id 41864 | +- P '100 | `- P '200 failure msg[Step 2. False Boolean Check(op) | {41864 <= 200}]
withRefined3TIO :: forall opts ip op fmt i m b. (MonadIO m, Refined3C opts ip op fmt i, Show (PP ip i), Show i) => i -> (Refined3 opts ip op fmt i -> RefinedT m b) -> RefinedT m b Source #
withRefined3TP :: forall opts ip op fmt i b proxy m. (Monad m, Refined3C opts ip op fmt i, Show (PP ip i), Show i) => proxy '(opts, ip, op, fmt, i) -> i -> (Refined3 opts ip op fmt i -> RefinedT m b) -> RefinedT m b Source #
proxy methods
mkProxy3 :: forall z opts ip op fmt i. z ~ '(opts, ip, op, fmt, i) => Proxy '(opts, ip, op, fmt, i) Source #
creates a 5-tuple proxy (see withRefined3TP
newRefined3TP
eval3P
prtEval3P
)
use type application to set the 5-tuple or set the individual parameters directly
set the 5-tuple directly
>>>
eg1 = mkProxy3 @'( OL, ReadP Int Id, Gt 10, ShowP Id, String)
>>>
newRefined3P eg1 "24"
Right (Refined3 {r3In = 24, r3Out = "24"})
skip the 5-tuple and set each parameter individually using type application
>>>
eg2 = mkProxy3 @_ @OL @(ReadP Int Id) @(Gt 10) @(ShowP Id)
>>>
newRefined3P eg2 "24"
Right (Refined3 {r3In = 24, r3Out = "24"})
mkProxy3' :: forall z opts ip op fmt i. (z ~ '(opts, ip, op, fmt, i), Refined3C opts ip op fmt i) => Proxy '(opts, ip, op, fmt, i) Source #
type family MakeR3 p where ... Source #
type family for converting from a 5-tuple '(opts,ip,op,fmt,i) to a Refined3
type
unsafe methods for creating Refined3
unsafeRefined3 :: forall opts ip op fmt i. PP ip i -> PP fmt (PP ip i) -> Refined3 opts ip op fmt i Source #
directly load values into Refined3
without any checking
unsafeRefined3' :: forall opts ip op fmt i. (HasCallStack, Show i, Show (PP ip i), Refined3C opts ip op fmt i) => i -> Refined3 opts ip op fmt i Source #
directly load values into Refined3
. It still checks to see that those values are valid
combine Refined3 values
convertRefined3TP :: forall opts ip op fmt i ip1 op1 fmt1 i1 m. (Refined3C opts ip op fmt i, Refined3C opts ip1 op1 fmt1 i1, Monad m, Show (PP ip i), PP ip i ~ PP ip1 i1, Show i1) => Proxy '(opts, ip, op, fmt, i) -> Proxy '(opts, ip1, op1, fmt1, i1) -> RefinedT m (Refined3 opts ip op fmt i) -> RefinedT m (Refined3 opts ip1 op1 fmt1 i1) Source #
rapply3 :: forall opts ip op fmt i m. (Refined3C opts ip op fmt i, Monad m, Show (PP ip i), Show i) => (PP ip i -> PP ip i -> PP ip i) -> RefinedT m (Refined3 opts ip op fmt i) -> RefinedT m (Refined3 opts ip op fmt i) -> RefinedT m (Refined3 opts ip op fmt i) Source #
applies a binary operation to two wrapped Refined3
parameters
rapply3P :: forall opts ip op fmt i proxy m. (Refined3C opts ip op fmt i, Monad m, Show (PP ip i), Show i) => proxy '(opts, ip, op, fmt, i) -> (PP ip i -> PP ip i -> PP ip i) -> RefinedT m (Refined3 opts ip op fmt i) -> RefinedT m (Refined3 opts ip op fmt i) -> RefinedT m (Refined3 opts ip op fmt i) Source #
same as rapply3
but uses a 5-tuple proxy instead
QuickCheck methods
genRefined3 :: forall opts ip op fmt i. Refined3C opts ip op fmt i => Gen (PP ip i) -> Gen (Refined3 opts ip op fmt i) Source #
create a Refined3
generator using a generator to restrict the values (so it completes)
>>>
g = genRefined3 @OU @(ReadP Int Id) @(Between 10 100 Id && Even) @(ShowP Id) (choose (10,100))
>>>
xs <- generate (vectorOf 10 g)
>>>
all (\x -> let y = r3In x in y >= 0 && y <= 100 && even y) xs
True
genRefined3P :: forall opts ip op fmt i. Refined3C opts ip op fmt i => Proxy '(opts, ip, op, fmt, i) -> Gen (PP ip i) -> Gen (Refined3 opts ip op fmt i) Source #
create a Refined3
generator using a proxy
emulate Refined3 using Refined
eval3PX :: forall opts ip op fmt i proxy. Refined3C opts ip op fmt i => proxy '(opts, ip, op, fmt, i) -> i -> (RResults3 (PP ip i) (PP fmt (PP ip i)), Maybe (Refined opts op (PP ip i), PP fmt (PP ip i))) Source #
similar to eval3P
but it emulates Refined3
using Refined
takes a 5-tuple proxy as input but outputs the Refined value and the result separately
- initial conversion using 'ip' and stores that in
Refined
- runs the boolean predicate 'op' to make sure to validate the converted value from 1.
- runs 'fmt' against the converted value from 1.
- returns both the
Refined
and the output from 3. - if any of the above steps fail the process stops it and dumps out
RResults3
eval3X :: forall opts ip op fmt i. Refined3C opts ip op fmt i => i -> (RResults3 (PP ip i) (PP fmt (PP ip i)), Maybe (Refined opts op (PP ip i), PP fmt (PP ip i))) Source #
same as eval3PX
but allows you to set the parameters individually using type application
type family ReplaceOptT3 (o :: OptT) t where ... Source #
replace the opts type
ReplaceOptT3 o (Refined3 _ ip op fmt i) = Refined3 o ip op fmt i |
type family AppendOptT3 (o :: OptT) t where ... Source #
change the opts type
AppendOptT3 o (Refined3 o' ip op fmt i) = Refined3 (o' :# o) ip op fmt i |