WO2MINIF4TXOHWSE7JWXRZYN64XRVLYIRFMF4SMPSOXKA2V77KMQC LAROLAYUGJ4Q5AEFV5EJMIA2ZKBNCBWHHHPCJ3CKCNIUIYUKRFVQC 7DBNV3GV773FH5ZLQWFX4RBOS4Q3CIK2RYZNNABY3ZOETYZCXRNQC NVOCQVASZWTKQJG7GPH7KHKZZR7NUG4WLV5YY4KAIRPCJRWCZPIAC GKGVYBZGPJXO7N7GLHLRNYQPXFHBQSNQN53OKRFCXLQEYDTC5I4QC Y35QCWYW2OTZ27ZVTH2BA3XJTUCJ2WMLKU32ZCOCDY3AW7TIZXRAC 64C6AWH66FDKU6UE6Z6JPX2J2GBM2JOPTH2GL6LHKAIUBGNGDZ5AC EMVTF2IWNQGRL44FC4JNG5FYYQTZSFPNM6SOM7IAEH6T7PPK2NVAC Z3M53KTLZMPOISMHE25SZJSWX5TA37IV33IRE7KNRAD3PKEAEJXQC WZUHEZSBRKHQMNWDKVG4X6DDIQEAXTGI6IGAJ5ERPRQ3W2KUMX4QC winningBids :: Foldable f -> Auction -> f Bid -> [Bid]winningBids =let
instance Ord Bid where(<=) b1 b2 =costRatio b1 <= costRatio b2where costRatio bid = (toRational . seconds $ bid) / (toRational . runBTC . btcAmount $ bid)-- lowest bids of seconds/btc winwinningBids :: Auction -> [Bid] -> [Bid]winningBids auction bids =let takeWinningBids :: BTC -> [Bid] -> [Bid]takeWinningBids total (x : xs)-- if the total is fully within the raise amount| total ++ btcAmount x < raiseAmount auction =x : (takeWinningBids (total ++ btcAmount x) xs)-- if the last bid will exceed the raise amount, reduce it to fit| total < raiseAmount auction =let remainder = raiseAmount auction <> invert totalwinFraction = (toRational . runBTC $ remainder) / (toRational . runBTC $ btcAmount x)remainderSeconds = Seconds . round $ winFraction * (toRational . seconds $ x)in [Bid (userId x) remainderSeconds remainder]| otherwise = []takeWinningBids _ [] = []in takeWinningBids mempty $ sort bids
build-depends: base >= 4 && < 5, bifunctors, classy-prelude >= 0.10.1, aeson >= 0.8.0.2, cassandra-cql >= 0.4.0.1, containers >= 0.5.5.1, either >= 4.3.1, lens >= 4.4.0.2, old-locale, sqlite == 0.5.2.2, text >= 1.2.0.0, time >= 1.4.2 && < 1.5
build-depends:base >= 4 && < 5, bifunctors, classy-prelude >= 0.10.1, aeson >= 0.8.0.2, cassandra-cql >= 0.4.0.1, containers >= 0.5.5.1, either >= 4.3.1, lens >= 4.4.0.2, old-locale, sqlite == 0.5.2.2, text >= 1.2, time >= 1.4.2 && < 1.5, hourglass >= 0.2.6 && < 0.3, groups >= 0.4