Auctions now compile!

[?]
Dec 6, 2014, 6:44 PM
WO2MINIF4TXOHWSE7JWXRZYN64XRVLYIRFMF4SMPSOXKA2V77KMQC

Dependencies

  • [2] LAROLAYU WIP
  • [3] GKGVYBZG Added JSON serialization to TimeLog
  • [4] 5W5M56VJ Move library code to 'lib'
  • [5] NVOCQVAS Initial failing tests.
  • [6] Y35QCWYW Minor improvement in WorkIndex type to eliminate duplicated information.
  • [7] EMVTF2IW WIP moving back to snap.
  • [8] WZUHEZSB Start of migration back toward snap.
  • [9] 64C6AWH6 Rename Ananke -> Quixotic, project reboot.
  • [10] Z3M53KTL Adrift.
  • [*] 7DBNV3GV Initial, stack-based impl of time log event reduction.

Change contents

  • edit in lib/Quixotic/Auction.hs at line 6
    [2.5213]
    [2.5213]
    import Data.Group
    import Data.Hourglass
    import Quixotic
    import Quixotic.Users
  • replacement in lib/Quixotic/Auction.hs at line 20
    [2.5360][2.5360:5379]()
    , hours :: Hours
    [2.5360]
    [2.5379]
    , seconds :: Seconds
  • replacement in lib/Quixotic/Auction.hs at line 22
    [2.5400][2.5400:5404]()
    }
    [2.5400]
    [2.5404]
    } deriving Eq
  • replacement in lib/Quixotic/Auction.hs at line 24
    [2.5405][2.5405:5482]()
    winningBids :: Foldable f -> Auction -> f Bid -> [Bid]
    winningBids =
    let
    [2.5405]
    instance Ord Bid where
    (<=) b1 b2 =
    costRatio b1 <= costRatio b2
    where costRatio bid = (toRational . seconds $ bid) / (toRational . runBTC . btcAmount $ bid)
    -- lowest bids of seconds/btc win
    winningBids :: 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 total
    winFraction = (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
  • edit in lib/Quixotic/Users.hs at line 6
    [2.6059]
    [2.6059]
    import Quixotic
  • replacement in lib/Quixotic/Users.hs at line 8
    [2.6060][2.6060:6088]()
    newtype UserId = UserId Int
    [2.6060]
    [2.6088]
    newtype UserId = UserId Int deriving (Show, Eq)
  • edit in lib/Quixotic.hs at line 6
    [12.1124]
    [3.2505]
    , BTC(..)
  • replacement in lib/Quixotic.hs at line 14
    [3.1808][3.2484:2530](),[3.2548][3.2484:2530]()
    --import Database.PostgreSQL.Simple.FromField
    [3.1787]
    [3.2592]
    import Data.Group
  • edit in lib/Quixotic.hs at line 18
    [3.2662]
    [12.1199]
    newtype BTC = BTC { runBTC :: Integer } deriving (Show, Eq, Ord)
    instance Semigroup BTC where
    (<>) b1 b2 = BTC $ runBTC b1 + runBTC b2
    instance Monoid BTC where
    mempty = BTC 0
    mappend = (<>)
    instance Group BTC where
    invert b = BTC . negate . runBTC $ b
    instance Abelian BTC where
  • replacement in quixotic.cabal at line 23
    [3.751][3.1152:1211](),[3.28][3.805:838](),[3.1211][3.805:838](),[3.805][3.805:838](),[3.838][2.6194:6247](),[3.1265][3.838:1311](),[2.6247][3.838:1311](),[3.838][3.838:1311]()
    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
    [3.751]
    [3.1311]
    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
  • replacement in quixotic.cabal at line 45
    [3.1496][3.1496:1706]()
    build-depends: quixotic
    , base
    , aeson
    , containers
    , text
    , time
    , hspec >= 1.8.1
    [3.1496]
    [3.1706]
    build-depends:
    quixotic
    , base
    , aeson
    , containers
    , text
    , time
    , hspec >= 1.8.1
  • replacement in quixotic.cabal at line 72
    [3.335][3.335:443]()
    , optparse-applicative >= 0.9.0 && < 0.10
    , bytestring >= 0.9.1 && < 0.11
    [3.335]
    [3.443]
    , optparse-applicative >= 0.9.0 && < 0.10
    , bytestring >= 0.9.1 && < 0.11