7NUEWNIMPWOFZAMPOK7QJH2AGZGS2SYTPZ5MVFI24KQG23WKRA2AC
A5WEQR35VYRX4XL5DWHFJPW3BGMIHIWFNCKG767LLNPMOIJ557MQC
44NEK2567V735JWLV2XABNGNW43WOIB5HSPVQJ6672TAP3K5VZZQC
SV5ID4TDECS35D2F4XYBVEFIIVOZYCHV6BTZBS7QYTOTJRDBGCIAC
DN2F55HBRBTHQAJDU4GOOGAEAXH5MIFPQSPEK2NNAPDJPZOOFJFQC
DOPKLXQZP3TDISHODQNI6GZ57EYE42NG225WHSZMQ3L355YVYPNAC
WRLD7PACYNQI2F3MAYAM5OK4RHO7CZ4OMYWAZ37UQY2IJ4AYS7LAC
deltaCopies delta category = R $ \card ->
let deltaNorm = PositiveNumber <$> (newCopies >>= eitherToMaybe . refine . fromIntegral)
categoryName = toText category
newCopies =
card ^. categories . at categoryName
<&> toNumber @Int
<&> (+ delta)
update x = card & (categories . ix (toText category)) .~ x
in update <$> deltaNorm
toNumber :: (Num a) => PositiveNumber -> a
toNumber = fromIntegral . unrefine . runNumber