{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE NumericUnderscores #-}
module Ouroboros.Network.Testing.Data.AbsBearerInfo
( AbsBearerInfoScript (..)
, canFail
, NonFailingAbsBearerInfoScript (..)
, AbsDelay (..)
, delay
, AbsSpeed (..)
, speedToRational
, delayAtSpeed
, AbsSDUSize (..)
, toSduSize
, AbsAttenuation (..)
, attenuation
, absNoAttenuation
, AbsBearerInfo (..)
, toNonFailingAbsBearerInfoScript
, AbsIOErrType (..)
) where
import Control.Monad.Class.MonadTime (DiffTime, Time (..), addTime)
import qualified Data.List as List
import qualified Data.List.NonEmpty as NonEmpty
import Data.Monoid (Any (..))
import Network.Mux.Bearer.AttenuatedChannel (Size,
SuccessOrFailure (..))
import Network.Mux.Types (SDUSize (..))
import Ouroboros.Network.Testing.Data.Script (Script (..))
import Ouroboros.Network.Testing.Utils (Delay (..))
import Test.QuickCheck (Arbitrary (..), Gen, arbitrarySizedNatural,
elements, frequency, listOf1, resize, shrinkList, suchThat)
data AbsDelay = SmallDelay
| NormalDelay
| LargeDelay
deriving (AbsDelay -> AbsDelay -> Bool
(AbsDelay -> AbsDelay -> Bool)
-> (AbsDelay -> AbsDelay -> Bool) -> Eq AbsDelay
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AbsDelay -> AbsDelay -> Bool
$c/= :: AbsDelay -> AbsDelay -> Bool
== :: AbsDelay -> AbsDelay -> Bool
$c== :: AbsDelay -> AbsDelay -> Bool
Eq, Eq AbsDelay
Eq AbsDelay
-> (AbsDelay -> AbsDelay -> Ordering)
-> (AbsDelay -> AbsDelay -> Bool)
-> (AbsDelay -> AbsDelay -> Bool)
-> (AbsDelay -> AbsDelay -> Bool)
-> (AbsDelay -> AbsDelay -> Bool)
-> (AbsDelay -> AbsDelay -> AbsDelay)
-> (AbsDelay -> AbsDelay -> AbsDelay)
-> Ord AbsDelay
AbsDelay -> AbsDelay -> Bool
AbsDelay -> AbsDelay -> Ordering
AbsDelay -> AbsDelay -> AbsDelay
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: AbsDelay -> AbsDelay -> AbsDelay
$cmin :: AbsDelay -> AbsDelay -> AbsDelay
max :: AbsDelay -> AbsDelay -> AbsDelay
$cmax :: AbsDelay -> AbsDelay -> AbsDelay
>= :: AbsDelay -> AbsDelay -> Bool
$c>= :: AbsDelay -> AbsDelay -> Bool
> :: AbsDelay -> AbsDelay -> Bool
$c> :: AbsDelay -> AbsDelay -> Bool
<= :: AbsDelay -> AbsDelay -> Bool
$c<= :: AbsDelay -> AbsDelay -> Bool
< :: AbsDelay -> AbsDelay -> Bool
$c< :: AbsDelay -> AbsDelay -> Bool
compare :: AbsDelay -> AbsDelay -> Ordering
$ccompare :: AbsDelay -> AbsDelay -> Ordering
$cp1Ord :: Eq AbsDelay
Ord, Int -> AbsDelay -> ShowS
[AbsDelay] -> ShowS
AbsDelay -> String
(Int -> AbsDelay -> ShowS)
-> (AbsDelay -> String) -> ([AbsDelay] -> ShowS) -> Show AbsDelay
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AbsDelay] -> ShowS
$cshowList :: [AbsDelay] -> ShowS
show :: AbsDelay -> String
$cshow :: AbsDelay -> String
showsPrec :: Int -> AbsDelay -> ShowS
$cshowsPrec :: Int -> AbsDelay -> ShowS
Show)
delay :: AbsDelay -> DiffTime
delay :: AbsDelay -> DiffTime
delay AbsDelay
SmallDelay = DiffTime
0.1
delay AbsDelay
NormalDelay = DiffTime
1
delay AbsDelay
LargeDelay = DiffTime
20
instance Arbitrary AbsDelay where
arbitrary :: Gen AbsDelay
arbitrary = [(Int, Gen AbsDelay)] -> Gen AbsDelay
forall a. [(Int, Gen a)] -> Gen a
frequency
[ (Int
1, AbsDelay -> Gen AbsDelay
forall (f :: * -> *) a. Applicative f => a -> f a
pure AbsDelay
SmallDelay)
, (Int
2, AbsDelay -> Gen AbsDelay
forall (f :: * -> *) a. Applicative f => a -> f a
pure AbsDelay
NormalDelay)
, (Int
1, AbsDelay -> Gen AbsDelay
forall (f :: * -> *) a. Applicative f => a -> f a
pure AbsDelay
LargeDelay)
]
shrink :: AbsDelay -> [AbsDelay]
shrink AbsDelay
SmallDelay = []
shrink AbsDelay
NormalDelay = [AbsDelay
SmallDelay]
shrink AbsDelay
LargeDelay = [AbsDelay
SmallDelay, AbsDelay
NormalDelay]
data AbsSpeed = SlowSpeed
| NormalSpeed
| FastSpeed
deriving (AbsSpeed -> AbsSpeed -> Bool
(AbsSpeed -> AbsSpeed -> Bool)
-> (AbsSpeed -> AbsSpeed -> Bool) -> Eq AbsSpeed
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AbsSpeed -> AbsSpeed -> Bool
$c/= :: AbsSpeed -> AbsSpeed -> Bool
== :: AbsSpeed -> AbsSpeed -> Bool
$c== :: AbsSpeed -> AbsSpeed -> Bool
Eq, Eq AbsSpeed
Eq AbsSpeed
-> (AbsSpeed -> AbsSpeed -> Ordering)
-> (AbsSpeed -> AbsSpeed -> Bool)
-> (AbsSpeed -> AbsSpeed -> Bool)
-> (AbsSpeed -> AbsSpeed -> Bool)
-> (AbsSpeed -> AbsSpeed -> Bool)
-> (AbsSpeed -> AbsSpeed -> AbsSpeed)
-> (AbsSpeed -> AbsSpeed -> AbsSpeed)
-> Ord AbsSpeed
AbsSpeed -> AbsSpeed -> Bool
AbsSpeed -> AbsSpeed -> Ordering
AbsSpeed -> AbsSpeed -> AbsSpeed
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: AbsSpeed -> AbsSpeed -> AbsSpeed
$cmin :: AbsSpeed -> AbsSpeed -> AbsSpeed
max :: AbsSpeed -> AbsSpeed -> AbsSpeed
$cmax :: AbsSpeed -> AbsSpeed -> AbsSpeed
>= :: AbsSpeed -> AbsSpeed -> Bool
$c>= :: AbsSpeed -> AbsSpeed -> Bool
> :: AbsSpeed -> AbsSpeed -> Bool
$c> :: AbsSpeed -> AbsSpeed -> Bool
<= :: AbsSpeed -> AbsSpeed -> Bool
$c<= :: AbsSpeed -> AbsSpeed -> Bool
< :: AbsSpeed -> AbsSpeed -> Bool
$c< :: AbsSpeed -> AbsSpeed -> Bool
compare :: AbsSpeed -> AbsSpeed -> Ordering
$ccompare :: AbsSpeed -> AbsSpeed -> Ordering
$cp1Ord :: Eq AbsSpeed
Ord, Int -> AbsSpeed -> ShowS
[AbsSpeed] -> ShowS
AbsSpeed -> String
(Int -> AbsSpeed -> ShowS)
-> (AbsSpeed -> String) -> ([AbsSpeed] -> ShowS) -> Show AbsSpeed
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AbsSpeed] -> ShowS
$cshowList :: [AbsSpeed] -> ShowS
show :: AbsSpeed -> String
$cshow :: AbsSpeed -> String
showsPrec :: Int -> AbsSpeed -> ShowS
$cshowsPrec :: Int -> AbsSpeed -> ShowS
Show)
instance Arbitrary AbsSpeed where
arbitrary :: Gen AbsSpeed
arbitrary = [(Int, Gen AbsSpeed)] -> Gen AbsSpeed
forall a. [(Int, Gen a)] -> Gen a
frequency
[ (Int
1, AbsSpeed -> Gen AbsSpeed
forall (f :: * -> *) a. Applicative f => a -> f a
pure AbsSpeed
SlowSpeed)
, (Int
2, AbsSpeed -> Gen AbsSpeed
forall (f :: * -> *) a. Applicative f => a -> f a
pure AbsSpeed
NormalSpeed)
, (Int
1, AbsSpeed -> Gen AbsSpeed
forall (f :: * -> *) a. Applicative f => a -> f a
pure AbsSpeed
FastSpeed)
]
shrink :: AbsSpeed -> [AbsSpeed]
shrink AbsSpeed
SlowSpeed = [AbsSpeed
FastSpeed, AbsSpeed
NormalSpeed]
shrink AbsSpeed
NormalSpeed = [AbsSpeed
FastSpeed]
shrink AbsSpeed
FastSpeed = []
speedToRational :: AbsSpeed -> Rational
speedToRational :: AbsSpeed -> Rational
speedToRational AbsSpeed
SlowSpeed = Rational
3057
speedToRational AbsSpeed
NormalSpeed = Rational
48912
speedToRational AbsSpeed
FastSpeed = Rational
1048576
delayAtSpeed :: AbsSpeed -> Size -> DiffTime
delayAtSpeed :: AbsSpeed -> Size -> DiffTime
delayAtSpeed AbsSpeed
speed Size
size = Rational -> DiffTime
forall a. Fractional a => Rational -> a
fromRational (Size -> Rational
forall a. Real a => a -> Rational
toRational Size
size Rational -> Rational -> Rational
forall a. Fractional a => a -> a -> a
/ AbsSpeed -> Rational
speedToRational AbsSpeed
speed)
data AbsSDUSize = SmallSDU
| NormalSDU
| LargeSDU
deriving (AbsSDUSize -> AbsSDUSize -> Bool
(AbsSDUSize -> AbsSDUSize -> Bool)
-> (AbsSDUSize -> AbsSDUSize -> Bool) -> Eq AbsSDUSize
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AbsSDUSize -> AbsSDUSize -> Bool
$c/= :: AbsSDUSize -> AbsSDUSize -> Bool
== :: AbsSDUSize -> AbsSDUSize -> Bool
$c== :: AbsSDUSize -> AbsSDUSize -> Bool
Eq, Int -> AbsSDUSize -> ShowS
[AbsSDUSize] -> ShowS
AbsSDUSize -> String
(Int -> AbsSDUSize -> ShowS)
-> (AbsSDUSize -> String)
-> ([AbsSDUSize] -> ShowS)
-> Show AbsSDUSize
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AbsSDUSize] -> ShowS
$cshowList :: [AbsSDUSize] -> ShowS
show :: AbsSDUSize -> String
$cshow :: AbsSDUSize -> String
showsPrec :: Int -> AbsSDUSize -> ShowS
$cshowsPrec :: Int -> AbsSDUSize -> ShowS
Show)
instance Arbitrary AbsSDUSize where
arbitrary :: Gen AbsSDUSize
arbitrary = [AbsSDUSize] -> Gen AbsSDUSize
forall a. [a] -> Gen a
elements [AbsSDUSize
SmallSDU, AbsSDUSize
NormalSDU, AbsSDUSize
LargeSDU]
shrink :: AbsSDUSize -> [AbsSDUSize]
shrink AbsSDUSize
SmallSDU = [AbsSDUSize
LargeSDU, AbsSDUSize
NormalSDU]
shrink AbsSDUSize
NormalSDU = [AbsSDUSize
LargeSDU]
shrink AbsSDUSize
LargeSDU = []
toSduSize :: AbsSDUSize -> SDUSize
toSduSize :: AbsSDUSize -> SDUSize
toSduSize AbsSDUSize
SmallSDU = Word16 -> SDUSize
SDUSize Word16
1_024
toSduSize AbsSDUSize
NormalSDU = Word16 -> SDUSize
SDUSize Word16
12_228
toSduSize AbsSDUSize
LargeSDU = Word16 -> SDUSize
SDUSize Word16
32_768
data AbsAttenuation =
NoAttenuation AbsSpeed
| SpeedAttenuation AbsSpeed Time DiffTime
| ErrorInterval AbsSpeed Time DiffTime
deriving (AbsAttenuation -> AbsAttenuation -> Bool
(AbsAttenuation -> AbsAttenuation -> Bool)
-> (AbsAttenuation -> AbsAttenuation -> Bool) -> Eq AbsAttenuation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AbsAttenuation -> AbsAttenuation -> Bool
$c/= :: AbsAttenuation -> AbsAttenuation -> Bool
== :: AbsAttenuation -> AbsAttenuation -> Bool
$c== :: AbsAttenuation -> AbsAttenuation -> Bool
Eq, Int -> AbsAttenuation -> ShowS
[AbsAttenuation] -> ShowS
AbsAttenuation -> String
(Int -> AbsAttenuation -> ShowS)
-> (AbsAttenuation -> String)
-> ([AbsAttenuation] -> ShowS)
-> Show AbsAttenuation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AbsAttenuation] -> ShowS
$cshowList :: [AbsAttenuation] -> ShowS
show :: AbsAttenuation -> String
$cshow :: AbsAttenuation -> String
showsPrec :: Int -> AbsAttenuation -> ShowS
$cshowsPrec :: Int -> AbsAttenuation -> ShowS
Show)
genTime :: Gen Time
genTime :: Gen Time
genTime = DiffTime -> Time
Time (DiffTime -> Time) -> (Delay -> DiffTime) -> Delay -> Time
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Delay -> DiffTime
getDelay (Delay -> Time) -> Gen Delay -> Gen Time
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Delay
forall a. Arbitrary a => Gen a
arbitrary
genLongDelay :: Gen DiffTime
genLongDelay :: Gen DiffTime
genLongDelay = Delay -> DiffTime
getDelay (Delay -> DiffTime) -> Gen Delay -> Gen DiffTime
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Gen Delay -> Gen Delay
forall a. Int -> Gen a -> Gen a
resize Int
1_000 Gen Delay
forall a. Arbitrary a => Gen a
arbitrary
instance Arbitrary AbsAttenuation where
arbitrary :: Gen AbsAttenuation
arbitrary =
[(Int, Gen AbsAttenuation)] -> Gen AbsAttenuation
forall a. [(Int, Gen a)] -> Gen a
frequency
[ (Int
2, AbsSpeed -> AbsAttenuation
NoAttenuation (AbsSpeed -> AbsAttenuation) -> Gen AbsSpeed -> Gen AbsAttenuation
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen AbsSpeed
forall a. Arbitrary a => Gen a
arbitrary)
, (Int
1, AbsSpeed -> Time -> DiffTime -> AbsAttenuation
SpeedAttenuation (AbsSpeed -> Time -> DiffTime -> AbsAttenuation)
-> Gen AbsSpeed -> Gen (Time -> DiffTime -> AbsAttenuation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen AbsSpeed
forall a. Arbitrary a => Gen a
arbitrary Gen AbsSpeed -> (AbsSpeed -> Bool) -> Gen AbsSpeed
forall a. Gen a -> (a -> Bool) -> Gen a
`suchThat` (AbsSpeed -> AbsSpeed -> Bool
forall a. Ord a => a -> a -> Bool
> AbsSpeed
SlowSpeed)
Gen (Time -> DiffTime -> AbsAttenuation)
-> Gen Time -> Gen (DiffTime -> AbsAttenuation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Time
genTime
Gen (DiffTime -> AbsAttenuation)
-> Gen DiffTime -> Gen AbsAttenuation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen DiffTime
genLongDelay
)
, (Int
1, AbsSpeed -> Time -> DiffTime -> AbsAttenuation
ErrorInterval (AbsSpeed -> Time -> DiffTime -> AbsAttenuation)
-> Gen AbsSpeed -> Gen (Time -> DiffTime -> AbsAttenuation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen AbsSpeed
forall a. Arbitrary a => Gen a
arbitrary
Gen (Time -> DiffTime -> AbsAttenuation)
-> Gen Time -> Gen (DiffTime -> AbsAttenuation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Time
genTime
Gen (DiffTime -> AbsAttenuation)
-> Gen DiffTime -> Gen AbsAttenuation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen DiffTime
genLongDelay
)
]
shrink :: AbsAttenuation -> [AbsAttenuation]
shrink (NoAttenuation AbsSpeed
speed) =
[AbsSpeed -> AbsAttenuation
NoAttenuation AbsSpeed
speed' | AbsSpeed
speed' <- AbsSpeed -> [AbsSpeed]
forall a. Arbitrary a => a -> [a]
shrink AbsSpeed
speed ]
shrink (SpeedAttenuation AbsSpeed
speed Time
time DiffTime
len) =
[ if DiffTime
len' DiffTime -> DiffTime -> Bool
forall a. Ord a => a -> a -> Bool
< DiffTime
1
then AbsSpeed -> AbsAttenuation
NoAttenuation AbsSpeed
speed
else AbsSpeed -> Time -> DiffTime -> AbsAttenuation
SpeedAttenuation AbsSpeed
speed Time
time DiffTime
len'
| Delay DiffTime
len' <- Delay -> [Delay]
forall a. Arbitrary a => a -> [a]
shrink (DiffTime -> Delay
Delay DiffTime
len)
]
shrink (ErrorInterval AbsSpeed
speed Time
time DiffTime
len) =
[ if DiffTime
len' DiffTime -> DiffTime -> Bool
forall a. Ord a => a -> a -> Bool
< DiffTime
1
then AbsSpeed -> AbsAttenuation
NoAttenuation AbsSpeed
speed
else AbsSpeed -> Time -> DiffTime -> AbsAttenuation
SpeedAttenuation AbsSpeed
speed Time
time DiffTime
len'
| Delay DiffTime
len' <- Delay -> [Delay]
forall a. Arbitrary a => a -> [a]
shrink (DiffTime -> Delay
Delay DiffTime
len)
]
attenuation :: AbsAttenuation
-> Time -> Size -> (DiffTime, SuccessOrFailure)
attenuation :: AbsAttenuation -> Time -> Size -> (DiffTime, SuccessOrFailure)
attenuation (NoAttenuation AbsSpeed
speed) =
\Time
_ Size
size -> (AbsSpeed -> Size -> DiffTime
delayAtSpeed AbsSpeed
speed Size
size, SuccessOrFailure
Success)
attenuation (SpeedAttenuation AbsSpeed
normalSpeed Time
from DiffTime
len) =
\Time
t Size
size ->
let speed :: AbsSpeed
speed = if Time
t Time -> Time -> Bool
forall a. Ord a => a -> a -> Bool
< Time
from Bool -> Bool -> Bool
|| Time
t Time -> Time -> Bool
forall a. Ord a => a -> a -> Bool
>= DiffTime
len DiffTime -> Time -> Time
`addTime` Time
from
then AbsSpeed
normalSpeed
else AbsSpeed
SlowSpeed
in ( AbsSpeed -> Size -> DiffTime
delayAtSpeed AbsSpeed
speed Size
size
, SuccessOrFailure
Success
)
attenuation (ErrorInterval AbsSpeed
speed Time
from DiffTime
len) =
\Time
t Size
size ->
( AbsSpeed -> Size -> DiffTime
delayAtSpeed AbsSpeed
speed Size
size
, if Time
t Time -> Time -> Bool
forall a. Ord a => a -> a -> Bool
< Time
from Bool -> Bool -> Bool
|| Time
t Time -> Time -> Bool
forall a. Ord a => a -> a -> Bool
>= DiffTime
len DiffTime -> Time -> Time
`addTime` Time
from
then SuccessOrFailure
Success
else SuccessOrFailure
Failure
)
data AbsIOErrType = AbsIOErrConnectionAborted
| AbsIOErrResourceExhausted
deriving (AbsIOErrType -> AbsIOErrType -> Bool
(AbsIOErrType -> AbsIOErrType -> Bool)
-> (AbsIOErrType -> AbsIOErrType -> Bool) -> Eq AbsIOErrType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AbsIOErrType -> AbsIOErrType -> Bool
$c/= :: AbsIOErrType -> AbsIOErrType -> Bool
== :: AbsIOErrType -> AbsIOErrType -> Bool
$c== :: AbsIOErrType -> AbsIOErrType -> Bool
Eq, Int -> AbsIOErrType -> ShowS
[AbsIOErrType] -> ShowS
AbsIOErrType -> String
(Int -> AbsIOErrType -> ShowS)
-> (AbsIOErrType -> String)
-> ([AbsIOErrType] -> ShowS)
-> Show AbsIOErrType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AbsIOErrType] -> ShowS
$cshowList :: [AbsIOErrType] -> ShowS
show :: AbsIOErrType -> String
$cshow :: AbsIOErrType -> String
showsPrec :: Int -> AbsIOErrType -> ShowS
$cshowsPrec :: Int -> AbsIOErrType -> ShowS
Show)
instance Arbitrary AbsIOErrType where
arbitrary :: Gen AbsIOErrType
arbitrary = [AbsIOErrType] -> Gen AbsIOErrType
forall a. [a] -> Gen a
elements [ AbsIOErrType
AbsIOErrConnectionAborted
, AbsIOErrType
AbsIOErrResourceExhausted
]
shrink :: AbsIOErrType -> [AbsIOErrType]
shrink AbsIOErrType
AbsIOErrConnectionAborted = [AbsIOErrType
AbsIOErrResourceExhausted]
shrink AbsIOErrType
AbsIOErrResourceExhausted = []
data AbsBearerInfo = AbsBearerInfo
{ AbsBearerInfo -> AbsDelay
abiConnectionDelay :: !AbsDelay
, AbsBearerInfo -> AbsAttenuation
abiInboundAttenuation :: !AbsAttenuation
, AbsBearerInfo -> AbsAttenuation
abiOutboundAttenuation :: !AbsAttenuation
, AbsBearerInfo -> Maybe Int
abiInboundWriteFailure :: !(Maybe Int)
, AbsBearerInfo -> Maybe Int
abiOutboundWriteFailure :: !(Maybe Int)
, AbsBearerInfo -> Maybe (AbsDelay, AbsIOErrType)
abiAcceptFailure :: !(Maybe ( AbsDelay
, AbsIOErrType
))
, AbsBearerInfo -> AbsSDUSize
abiSDUSize :: !AbsSDUSize
}
deriving (AbsBearerInfo -> AbsBearerInfo -> Bool
(AbsBearerInfo -> AbsBearerInfo -> Bool)
-> (AbsBearerInfo -> AbsBearerInfo -> Bool) -> Eq AbsBearerInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AbsBearerInfo -> AbsBearerInfo -> Bool
$c/= :: AbsBearerInfo -> AbsBearerInfo -> Bool
== :: AbsBearerInfo -> AbsBearerInfo -> Bool
$c== :: AbsBearerInfo -> AbsBearerInfo -> Bool
Eq, Int -> AbsBearerInfo -> ShowS
[AbsBearerInfo] -> ShowS
AbsBearerInfo -> String
(Int -> AbsBearerInfo -> ShowS)
-> (AbsBearerInfo -> String)
-> ([AbsBearerInfo] -> ShowS)
-> Show AbsBearerInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AbsBearerInfo] -> ShowS
$cshowList :: [AbsBearerInfo] -> ShowS
show :: AbsBearerInfo -> String
$cshow :: AbsBearerInfo -> String
showsPrec :: Int -> AbsBearerInfo -> ShowS
$cshowsPrec :: Int -> AbsBearerInfo -> ShowS
Show)
absNoAttenuation :: AbsBearerInfo
absNoAttenuation :: AbsBearerInfo
absNoAttenuation = AbsBearerInfo :: AbsDelay
-> AbsAttenuation
-> AbsAttenuation
-> Maybe Int
-> Maybe Int
-> Maybe (AbsDelay, AbsIOErrType)
-> AbsSDUSize
-> AbsBearerInfo
AbsBearerInfo
{ abiConnectionDelay :: AbsDelay
abiConnectionDelay = AbsDelay
NormalDelay
, abiInboundAttenuation :: AbsAttenuation
abiInboundAttenuation = AbsSpeed -> AbsAttenuation
NoAttenuation AbsSpeed
NormalSpeed
, abiOutboundAttenuation :: AbsAttenuation
abiOutboundAttenuation = AbsSpeed -> AbsAttenuation
NoAttenuation AbsSpeed
NormalSpeed
, abiInboundWriteFailure :: Maybe Int
abiInboundWriteFailure = Maybe Int
forall a. Maybe a
Nothing
, abiOutboundWriteFailure :: Maybe Int
abiOutboundWriteFailure = Maybe Int
forall a. Maybe a
Nothing
, abiAcceptFailure :: Maybe (AbsDelay, AbsIOErrType)
abiAcceptFailure = Maybe (AbsDelay, AbsIOErrType)
forall a. Maybe a
Nothing
, abiSDUSize :: AbsSDUSize
abiSDUSize = AbsSDUSize
NormalSDU
}
canFail :: AbsBearerInfo -> Bool
canFail :: AbsBearerInfo -> Bool
canFail AbsBearerInfo
abi = Any -> Bool
getAny (Any -> Bool) -> Any -> Bool
forall a b. (a -> b) -> a -> b
$
case AbsBearerInfo -> AbsAttenuation
abiInboundAttenuation AbsBearerInfo
abi of
NoAttenuation {} -> Bool -> Any
Any Bool
False
AbsAttenuation
_ -> Bool -> Any
Any Bool
True
Any -> Any -> Any
forall a. Semigroup a => a -> a -> a
<> case AbsBearerInfo -> AbsAttenuation
abiOutboundAttenuation AbsBearerInfo
abi of
NoAttenuation {} -> Bool -> Any
Any Bool
False
AbsAttenuation
_ -> Bool -> Any
Any Bool
True
Any -> Any -> Any
forall a. Semigroup a => a -> a -> a
<> case AbsBearerInfo -> Maybe Int
abiInboundWriteFailure AbsBearerInfo
abi of
Maybe Int
Nothing -> Bool -> Any
Any Bool
False
Maybe Int
_ -> Bool -> Any
Any Bool
True
Any -> Any -> Any
forall a. Semigroup a => a -> a -> a
<> case AbsBearerInfo -> Maybe Int
abiOutboundWriteFailure AbsBearerInfo
abi of
Maybe Int
Nothing -> Bool -> Any
Any Bool
False
Maybe Int
_ -> Bool -> Any
Any Bool
True
Any -> Any -> Any
forall a. Semigroup a => a -> a -> a
<> case AbsBearerInfo -> Maybe (AbsDelay, AbsIOErrType)
abiAcceptFailure AbsBearerInfo
abi of
Maybe (AbsDelay, AbsIOErrType)
Nothing -> Bool -> Any
Any Bool
False
Maybe (AbsDelay, AbsIOErrType)
_ -> Bool -> Any
Any Bool
True
instance Arbitrary AbsBearerInfo where
arbitrary :: Gen AbsBearerInfo
arbitrary =
AbsDelay
-> AbsAttenuation
-> AbsAttenuation
-> Maybe Int
-> Maybe Int
-> Maybe (AbsDelay, AbsIOErrType)
-> AbsSDUSize
-> AbsBearerInfo
AbsBearerInfo (AbsDelay
-> AbsAttenuation
-> AbsAttenuation
-> Maybe Int
-> Maybe Int
-> Maybe (AbsDelay, AbsIOErrType)
-> AbsSDUSize
-> AbsBearerInfo)
-> Gen AbsDelay
-> Gen
(AbsAttenuation
-> AbsAttenuation
-> Maybe Int
-> Maybe Int
-> Maybe (AbsDelay, AbsIOErrType)
-> AbsSDUSize
-> AbsBearerInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen AbsDelay
forall a. Arbitrary a => Gen a
arbitrary
Gen
(AbsAttenuation
-> AbsAttenuation
-> Maybe Int
-> Maybe Int
-> Maybe (AbsDelay, AbsIOErrType)
-> AbsSDUSize
-> AbsBearerInfo)
-> Gen AbsAttenuation
-> Gen
(AbsAttenuation
-> Maybe Int
-> Maybe Int
-> Maybe (AbsDelay, AbsIOErrType)
-> AbsSDUSize
-> AbsBearerInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen AbsAttenuation
forall a. Arbitrary a => Gen a
arbitrary
Gen
(AbsAttenuation
-> Maybe Int
-> Maybe Int
-> Maybe (AbsDelay, AbsIOErrType)
-> AbsSDUSize
-> AbsBearerInfo)
-> Gen AbsAttenuation
-> Gen
(Maybe Int
-> Maybe Int
-> Maybe (AbsDelay, AbsIOErrType)
-> AbsSDUSize
-> AbsBearerInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen AbsAttenuation
forall a. Arbitrary a => Gen a
arbitrary
Gen
(Maybe Int
-> Maybe Int
-> Maybe (AbsDelay, AbsIOErrType)
-> AbsSDUSize
-> AbsBearerInfo)
-> Gen (Maybe Int)
-> Gen
(Maybe Int
-> Maybe (AbsDelay, AbsIOErrType) -> AbsSDUSize -> AbsBearerInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (Maybe Int)
genWriteFailure
Gen
(Maybe Int
-> Maybe (AbsDelay, AbsIOErrType) -> AbsSDUSize -> AbsBearerInfo)
-> Gen (Maybe Int)
-> Gen
(Maybe (AbsDelay, AbsIOErrType) -> AbsSDUSize -> AbsBearerInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (Maybe Int)
genWriteFailure
Gen (Maybe (AbsDelay, AbsIOErrType) -> AbsSDUSize -> AbsBearerInfo)
-> Gen (Maybe (AbsDelay, AbsIOErrType))
-> Gen (AbsSDUSize -> AbsBearerInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (Maybe (AbsDelay, AbsIOErrType))
genAcceptFailure
Gen (AbsSDUSize -> AbsBearerInfo)
-> Gen AbsSDUSize -> Gen AbsBearerInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen AbsSDUSize
forall a. Arbitrary a => Gen a
arbitrary
where
genWriteFailure :: Gen (Maybe Int)
genWriteFailure =
[(Int, Gen (Maybe Int))] -> Gen (Maybe Int)
forall a. [(Int, Gen a)] -> Gen a
frequency
[ (Int
2, Maybe Int -> Gen (Maybe Int)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Int
forall a. Maybe a
Nothing)
, (Int
1, Int -> Maybe Int
forall a. a -> Maybe a
Just (Int -> Maybe Int) -> Gen Int -> Gen (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Int
forall a. Integral a => Gen a
arbitrarySizedNatural)
]
genAcceptFailure :: Gen (Maybe (AbsDelay, AbsIOErrType))
genAcceptFailure =
[(Int, Gen (Maybe (AbsDelay, AbsIOErrType)))]
-> Gen (Maybe (AbsDelay, AbsIOErrType))
forall a. [(Int, Gen a)] -> Gen a
frequency
[ (Int
2, Maybe (AbsDelay, AbsIOErrType)
-> Gen (Maybe (AbsDelay, AbsIOErrType))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (AbsDelay, AbsIOErrType)
forall a. Maybe a
Nothing)
, (Int
1, (\AbsDelay
a AbsIOErrType
b -> (AbsDelay, AbsIOErrType) -> Maybe (AbsDelay, AbsIOErrType)
forall a. a -> Maybe a
Just (AbsDelay
a,AbsIOErrType
b)) (AbsDelay -> AbsIOErrType -> Maybe (AbsDelay, AbsIOErrType))
-> Gen AbsDelay
-> Gen (AbsIOErrType -> Maybe (AbsDelay, AbsIOErrType))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen AbsDelay
forall a. Arbitrary a => Gen a
arbitrary Gen (AbsIOErrType -> Maybe (AbsDelay, AbsIOErrType))
-> Gen AbsIOErrType -> Gen (Maybe (AbsDelay, AbsIOErrType))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen AbsIOErrType
forall a. Arbitrary a => Gen a
arbitrary)
]
shrink :: AbsBearerInfo -> [AbsBearerInfo]
shrink AbsBearerInfo
abi =
[ AbsBearerInfo
abi { abiConnectionDelay :: AbsDelay
abiConnectionDelay = AbsDelay
connDelay }
| AbsDelay
connDelay <- AbsDelay -> [AbsDelay]
forall a. Arbitrary a => a -> [a]
shrink (AbsBearerInfo -> AbsDelay
abiConnectionDelay AbsBearerInfo
abi) ]
[AbsBearerInfo] -> [AbsBearerInfo] -> [AbsBearerInfo]
forall a. [a] -> [a] -> [a]
++
[ AbsBearerInfo
abi { abiInboundAttenuation :: AbsAttenuation
abiInboundAttenuation = AbsAttenuation
a }
| AbsAttenuation
a <- AbsAttenuation -> [AbsAttenuation]
forall a. Arbitrary a => a -> [a]
shrink (AbsBearerInfo -> AbsAttenuation
abiInboundAttenuation AbsBearerInfo
abi) ]
[AbsBearerInfo] -> [AbsBearerInfo] -> [AbsBearerInfo]
forall a. [a] -> [a] -> [a]
++
[ AbsBearerInfo
abi { abiOutboundAttenuation :: AbsAttenuation
abiOutboundAttenuation = AbsAttenuation
a }
| AbsAttenuation
a <- AbsAttenuation -> [AbsAttenuation]
forall a. Arbitrary a => a -> [a]
shrink (AbsBearerInfo -> AbsAttenuation
abiOutboundAttenuation AbsBearerInfo
abi) ]
[AbsBearerInfo] -> [AbsBearerInfo] -> [AbsBearerInfo]
forall a. [a] -> [a] -> [a]
++
[ AbsBearerInfo
abi { abiInboundWriteFailure :: Maybe Int
abiInboundWriteFailure = Maybe Int
a }
| Maybe Int
a <- Maybe Int -> [Maybe Int]
forall a. Arbitrary a => a -> [a]
shrink (AbsBearerInfo -> Maybe Int
abiInboundWriteFailure AbsBearerInfo
abi) ]
[AbsBearerInfo] -> [AbsBearerInfo] -> [AbsBearerInfo]
forall a. [a] -> [a] -> [a]
++
[ AbsBearerInfo
abi { abiOutboundWriteFailure :: Maybe Int
abiOutboundWriteFailure = Maybe Int
a }
| Maybe Int
a <- Maybe Int -> [Maybe Int]
forall a. Arbitrary a => a -> [a]
shrink (AbsBearerInfo -> Maybe Int
abiOutboundWriteFailure AbsBearerInfo
abi) ]
[AbsBearerInfo] -> [AbsBearerInfo] -> [AbsBearerInfo]
forall a. [a] -> [a] -> [a]
++
[ AbsBearerInfo
abi { abiSDUSize :: AbsSDUSize
abiSDUSize = AbsSDUSize
a }
| AbsSDUSize
a <- AbsSDUSize -> [AbsSDUSize]
forall a. Arbitrary a => a -> [a]
shrink (AbsBearerInfo -> AbsSDUSize
abiSDUSize AbsBearerInfo
abi)
]
newtype AbsBearerInfoScript =
AbsBearerInfoScript { AbsBearerInfoScript -> Script AbsBearerInfo
unBIScript :: Script AbsBearerInfo }
deriving Int -> AbsBearerInfoScript -> ShowS
[AbsBearerInfoScript] -> ShowS
AbsBearerInfoScript -> String
(Int -> AbsBearerInfoScript -> ShowS)
-> (AbsBearerInfoScript -> String)
-> ([AbsBearerInfoScript] -> ShowS)
-> Show AbsBearerInfoScript
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AbsBearerInfoScript] -> ShowS
$cshowList :: [AbsBearerInfoScript] -> ShowS
show :: AbsBearerInfoScript -> String
$cshow :: AbsBearerInfoScript -> String
showsPrec :: Int -> AbsBearerInfoScript -> ShowS
$cshowsPrec :: Int -> AbsBearerInfoScript -> ShowS
Show via (Script AbsBearerInfo)
deriving stock AbsBearerInfoScript -> AbsBearerInfoScript -> Bool
(AbsBearerInfoScript -> AbsBearerInfoScript -> Bool)
-> (AbsBearerInfoScript -> AbsBearerInfoScript -> Bool)
-> Eq AbsBearerInfoScript
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AbsBearerInfoScript -> AbsBearerInfoScript -> Bool
$c/= :: AbsBearerInfoScript -> AbsBearerInfoScript -> Bool
== :: AbsBearerInfoScript -> AbsBearerInfoScript -> Bool
$c== :: AbsBearerInfoScript -> AbsBearerInfoScript -> Bool
Eq
fixupAbsBearerInfos :: [AbsBearerInfo] -> [AbsBearerInfo]
fixupAbsBearerInfos :: [AbsBearerInfo] -> [AbsBearerInfo]
fixupAbsBearerInfos [AbsBearerInfo]
bis =
if AbsBearerInfo -> Bool
canFail ([AbsBearerInfo] -> AbsBearerInfo
forall a. [a] -> a
last [AbsBearerInfo]
bis)
then [AbsBearerInfo]
bis [AbsBearerInfo] -> [AbsBearerInfo] -> [AbsBearerInfo]
forall a. [a] -> [a] -> [a]
++ [AbsBearerInfo
absNoAttenuation]
else [AbsBearerInfo]
bis
instance Arbitrary AbsBearerInfoScript where
arbitrary :: Gen AbsBearerInfoScript
arbitrary = Script AbsBearerInfo -> AbsBearerInfoScript
AbsBearerInfoScript
(Script AbsBearerInfo -> AbsBearerInfoScript)
-> ([AbsBearerInfo] -> Script AbsBearerInfo)
-> [AbsBearerInfo]
-> AbsBearerInfoScript
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty AbsBearerInfo -> Script AbsBearerInfo
forall a. NonEmpty a -> Script a
Script
(NonEmpty AbsBearerInfo -> Script AbsBearerInfo)
-> ([AbsBearerInfo] -> NonEmpty AbsBearerInfo)
-> [AbsBearerInfo]
-> Script AbsBearerInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [AbsBearerInfo] -> NonEmpty AbsBearerInfo
forall a. [a] -> NonEmpty a
NonEmpty.fromList
([AbsBearerInfo] -> NonEmpty AbsBearerInfo)
-> ([AbsBearerInfo] -> [AbsBearerInfo])
-> [AbsBearerInfo]
-> NonEmpty AbsBearerInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [AbsBearerInfo] -> [AbsBearerInfo]
fixupAbsBearerInfos
([AbsBearerInfo] -> AbsBearerInfoScript)
-> Gen [AbsBearerInfo] -> Gen AbsBearerInfoScript
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen AbsBearerInfo -> Gen [AbsBearerInfo]
forall a. Gen a -> Gen [a]
listOf1 Gen AbsBearerInfo
forall a. Arbitrary a => Gen a
arbitrary
shrink :: AbsBearerInfoScript -> [AbsBearerInfoScript]
shrink (AbsBearerInfoScript (Script NonEmpty AbsBearerInfo
script)) =
[ Script AbsBearerInfo -> AbsBearerInfoScript
AbsBearerInfoScript (NonEmpty AbsBearerInfo -> Script AbsBearerInfo
forall a. NonEmpty a -> Script a
Script NonEmpty AbsBearerInfo
script')
| NonEmpty AbsBearerInfo
script'
<- ([AbsBearerInfo] -> NonEmpty AbsBearerInfo)
-> [[AbsBearerInfo]] -> [NonEmpty AbsBearerInfo]
forall a b. (a -> b) -> [a] -> [b]
map ([AbsBearerInfo] -> NonEmpty AbsBearerInfo
forall a. [a] -> NonEmpty a
NonEmpty.fromList ([AbsBearerInfo] -> NonEmpty AbsBearerInfo)
-> ([AbsBearerInfo] -> [AbsBearerInfo])
-> [AbsBearerInfo]
-> NonEmpty AbsBearerInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [AbsBearerInfo] -> [AbsBearerInfo]
fixupAbsBearerInfos)
([[AbsBearerInfo]] -> [NonEmpty AbsBearerInfo])
-> ([[AbsBearerInfo]] -> [[AbsBearerInfo]])
-> [[AbsBearerInfo]]
-> [NonEmpty AbsBearerInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([AbsBearerInfo] -> Bool) -> [[AbsBearerInfo]] -> [[AbsBearerInfo]]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> ([AbsBearerInfo] -> Bool) -> [AbsBearerInfo] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [AbsBearerInfo] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
List.null)
([[AbsBearerInfo]] -> [NonEmpty AbsBearerInfo])
-> [[AbsBearerInfo]] -> [NonEmpty AbsBearerInfo]
forall a b. (a -> b) -> a -> b
$ (AbsBearerInfo -> [AbsBearerInfo])
-> [AbsBearerInfo] -> [[AbsBearerInfo]]
forall a. (a -> [a]) -> [a] -> [[a]]
shrinkList ([AbsBearerInfo] -> AbsBearerInfo -> [AbsBearerInfo]
forall a b. a -> b -> a
const []) (NonEmpty AbsBearerInfo -> [AbsBearerInfo]
forall a. NonEmpty a -> [a]
NonEmpty.toList NonEmpty AbsBearerInfo
script)
, NonEmpty AbsBearerInfo
script' NonEmpty AbsBearerInfo -> NonEmpty AbsBearerInfo -> Bool
forall a. Eq a => a -> a -> Bool
/= NonEmpty AbsBearerInfo
script
]
newtype NonFailingAbsBearerInfoScript =
NonFailingAbsBearerInfoScript { NonFailingAbsBearerInfoScript -> Script AbsBearerInfo
unNFBIScript :: Script AbsBearerInfo }
deriving Int -> NonFailingAbsBearerInfoScript -> ShowS
[NonFailingAbsBearerInfoScript] -> ShowS
NonFailingAbsBearerInfoScript -> String
(Int -> NonFailingAbsBearerInfoScript -> ShowS)
-> (NonFailingAbsBearerInfoScript -> String)
-> ([NonFailingAbsBearerInfoScript] -> ShowS)
-> Show NonFailingAbsBearerInfoScript
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NonFailingAbsBearerInfoScript] -> ShowS
$cshowList :: [NonFailingAbsBearerInfoScript] -> ShowS
show :: NonFailingAbsBearerInfoScript -> String
$cshow :: NonFailingAbsBearerInfoScript -> String
showsPrec :: Int -> NonFailingAbsBearerInfoScript -> ShowS
$cshowsPrec :: Int -> NonFailingAbsBearerInfoScript -> ShowS
Show via (Script AbsBearerInfo)
deriving stock NonFailingAbsBearerInfoScript
-> NonFailingAbsBearerInfoScript -> Bool
(NonFailingAbsBearerInfoScript
-> NonFailingAbsBearerInfoScript -> Bool)
-> (NonFailingAbsBearerInfoScript
-> NonFailingAbsBearerInfoScript -> Bool)
-> Eq NonFailingAbsBearerInfoScript
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NonFailingAbsBearerInfoScript
-> NonFailingAbsBearerInfoScript -> Bool
$c/= :: NonFailingAbsBearerInfoScript
-> NonFailingAbsBearerInfoScript -> Bool
== :: NonFailingAbsBearerInfoScript
-> NonFailingAbsBearerInfoScript -> Bool
$c== :: NonFailingAbsBearerInfoScript
-> NonFailingAbsBearerInfoScript -> Bool
Eq
toNonFailingAbsBearerInfoScript :: AbsBearerInfoScript
-> NonFailingAbsBearerInfoScript
toNonFailingAbsBearerInfoScript :: AbsBearerInfoScript -> NonFailingAbsBearerInfoScript
toNonFailingAbsBearerInfoScript (AbsBearerInfoScript Script AbsBearerInfo
script) =
Script AbsBearerInfo -> NonFailingAbsBearerInfoScript
NonFailingAbsBearerInfoScript (Script AbsBearerInfo -> NonFailingAbsBearerInfoScript)
-> Script AbsBearerInfo -> NonFailingAbsBearerInfoScript
forall a b. (a -> b) -> a -> b
$ (AbsBearerInfo -> AbsBearerInfo)
-> Script AbsBearerInfo -> Script AbsBearerInfo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AbsBearerInfo -> AbsBearerInfo
unfail Script AbsBearerInfo
script
where
unfail :: AbsBearerInfo -> AbsBearerInfo
unfail :: AbsBearerInfo -> AbsBearerInfo
unfail AbsBearerInfo
bi =
AbsBearerInfo
bi { abiInboundWriteFailure :: Maybe Int
abiInboundWriteFailure = Maybe Int
forall a. Maybe a
Nothing
, abiOutboundWriteFailure :: Maybe Int
abiOutboundWriteFailure = Maybe Int
forall a. Maybe a
Nothing
, abiInboundAttenuation :: AbsAttenuation
abiInboundAttenuation = AbsAttenuation -> AbsAttenuation
unfailAtt (AbsAttenuation -> AbsAttenuation)
-> AbsAttenuation -> AbsAttenuation
forall a b. (a -> b) -> a -> b
$ AbsBearerInfo -> AbsAttenuation
abiInboundAttenuation AbsBearerInfo
bi
, abiOutboundAttenuation :: AbsAttenuation
abiOutboundAttenuation = AbsAttenuation -> AbsAttenuation
unfailAtt (AbsAttenuation -> AbsAttenuation)
-> AbsAttenuation -> AbsAttenuation
forall a b. (a -> b) -> a -> b
$ AbsBearerInfo -> AbsAttenuation
abiOutboundAttenuation AbsBearerInfo
bi
, abiAcceptFailure :: Maybe (AbsDelay, AbsIOErrType)
abiAcceptFailure = Maybe (AbsDelay, AbsIOErrType)
forall a. Maybe a
Nothing
}
unfailAtt :: AbsAttenuation -> AbsAttenuation
unfailAtt (ErrorInterval AbsSpeed
speed Time
_ DiffTime
_) = AbsSpeed -> AbsAttenuation
NoAttenuation AbsSpeed
speed
unfailAtt (SpeedAttenuation AbsSpeed
speed Time
_ DiffTime
_) = AbsSpeed -> AbsAttenuation
NoAttenuation AbsSpeed
speed
unfailAtt AbsAttenuation
a = AbsAttenuation
a
instance Arbitrary NonFailingAbsBearerInfoScript where
arbitrary :: Gen NonFailingAbsBearerInfoScript
arbitrary = AbsBearerInfoScript -> NonFailingAbsBearerInfoScript
toNonFailingAbsBearerInfoScript (AbsBearerInfoScript -> NonFailingAbsBearerInfoScript)
-> Gen AbsBearerInfoScript -> Gen NonFailingAbsBearerInfoScript
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen AbsBearerInfoScript
forall a. Arbitrary a => Gen a
arbitrary
shrink :: NonFailingAbsBearerInfoScript -> [NonFailingAbsBearerInfoScript]
shrink (NonFailingAbsBearerInfoScript Script AbsBearerInfo
script) =
AbsBearerInfoScript -> NonFailingAbsBearerInfoScript
toNonFailingAbsBearerInfoScript (AbsBearerInfoScript -> NonFailingAbsBearerInfoScript)
-> [AbsBearerInfoScript] -> [NonFailingAbsBearerInfoScript]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AbsBearerInfoScript -> [AbsBearerInfoScript]
forall a. Arbitrary a => a -> [a]
shrink (Script AbsBearerInfo -> AbsBearerInfoScript
AbsBearerInfoScript Script AbsBearerInfo
script)