B:BD[
8.230] → [
8.230:380]
B:BD[
8.380] → [
9.205:510]
B:BD[
9.510] → [
5.1201:1266]
let chQ = ChangeQuantity (name x) (runQuantity y - runQuantity x)
chC = ChangeCategory (name x) (category x) (category y)
in case (partialEqCard quantity x y, partialEqCard category x y) of
(True, True) -> go acc xs ys
(False, False) -> go (chQ : chC : acc) xs ys
(False, _) -> go (chQ : acc) xs ys
(_, False) -> go (chC : acc) xs ys
runQuantity = fromIntegral . unrefine . runNumber . quantity
case (partialEqCard quantity x y, partialEqCard category x y) of
(True, True) -> go acc xs ys
(False, False) -> go (ChangeCard (name x) (calcQuantity x y) (const $ category y) : acc) xs ys
(False, _) -> go (ChangeCard (name x) (calcQuantity x y) id : acc) xs ys
(_, False) -> go (ChangeCard (name x) Just (const $ category y) : acc) xs ys
runQuantity = fromIntegral @_ @Int . unrefine . runNumber . quantity
delta x y = runQuantity y - runQuantity x
newQuantity a
| a < 1 = Nothing
| otherwise = PositiveNumber <$> (refineFail . fromIntegral $ a)
calcQuantity x y = newQuantity . (+ delta x y) . fromIntegral . unrefine . runNumber