More progression toward lenses.

[?]
Dec 9, 2014, 8:59 PM
75N3UJ4JK56KXF56GASGPAWLFYGJDETVJNYTF4KXFCQM767JUU5AC

Dependencies

  • [2] WO2MINIF Auctions now compile!
  • [3] TZQJVHBA Add auction functions to ADB.
  • [4] GKGVYBZG Added JSON serialization to TimeLog
  • [5] 64C6AWH6 Rename Ananke -> Quixotic, project reboot.
  • [6] 64VI73NP Server now compiles using abstracted SQLite
  • [7] EMVTF2IW WIP moving back to snap.
  • [8] LAROLAYU WIP
  • [9] NVOCQVAS Initial failing tests.
  • [10] 5W5M56VJ Move library code to 'lib'
  • [11] 7DBNV3GV Initial, stack-based impl of time log event reduction.
  • [12] Y35QCWYW Minor improvement in WorkIndex type to eliminate duplicated information.
  • [13] WFZDMVUX Rename ADB -> QDB
  • [*] FRPWIKCN Added log event parsing to Quixotic.Database.SQLite

Change contents

  • replacement in lib/Quixotic/Auction.hs at line 1
    [4.5084][4.5085:5160]()
    {-# LANGUAGE ScopedTypeVariables, OverloadedStrings, NoImplicitPrelude #-}
    [4.5084]
    [4.5160]
    {-# LANGUAGE ScopedTypeVariables, OverloadedStrings, NoImplicitPrelude, TemplateHaskell #-}
  • edit in lib/Quixotic/Auction.hs at line 6
    [4.5213]
    [2.3]
    import Control.Lens
  • replacement in lib/Quixotic/Auction.hs at line 15
    [4.5273][4.5273:5319]()
    { raiseAmount :: BTC
    , endsAt :: UTCTime
    [4.5273]
    [4.5319]
    { _raiseAmount :: BTC
    , _endsAt :: UTCTime
  • edit in lib/Quixotic/Auction.hs at line 19
    [4.5324]
    [4.5324]
    makeLenses ''Auction
  • replacement in lib/Quixotic/Auction.hs at line 22
    [4.5339][4.5339:5360](),[4.5360][2.82:105](),[2.105][4.5379:5400](),[4.5379][4.5379:5400]()
    { userId :: UserId
    , seconds :: Seconds
    , btcAmount :: BTC
    [4.5339]
    [2.106]
    { _userId :: UserId
    , _seconds :: Seconds
    , _btcAmount :: BTC
  • edit in lib/Quixotic/Auction.hs at line 27
    [4.5405]
    [2.123]
    makeLenses ''Bid
  • replacement in lib/Quixotic/Auction.hs at line 32
    [2.195][2.195:293]()
    where costRatio bid = (toRational . seconds $ bid) / (toRational . runBTC . btcAmount $ bid)
    [2.195]
    [2.293]
    where
    bidSeconds bid = toRational $ bid ^. seconds
    bidAmount bid = toRational $ bid ^. (btcAmount . btc)
    costRatio bid = bidSeconds bid / bidAmount bid
  • replacement in lib/Quixotic/Auction.hs at line 43
    [2.538][2.538:652]()
    | total ++ btcAmount x < raiseAmount auction =
    x : (takeWinningBids (total ++ btcAmount x) xs)
    [2.538]
    [2.652]
    | (total ++ x ^. btcAmount) < (auction ^. raiseAmount) =
    x : (takeWinningBids (total ++ x ^. btcAmount) xs)
  • replacement in lib/Quixotic/Auction.hs at line 47
    [2.727][2.727:1080]()
    | 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]
    [2.727]
    [2.1080]
    | total < auction ^. raiseAmount =
    let remainder = (auction ^. raiseAmount) ++ invert total
    winFraction :: Rational
    winFraction = (toRational $ remainder ^. btc) / (toRational $ x ^. (btcAmount . btc))
    remainderSeconds = Seconds . round $ winFraction * (toRational $ x ^. seconds)
    in [x & seconds .~ remainderSeconds & btcAmount .~ remainder]
  • edit in lib/Quixotic/Database/SQLite.hs at line 6
    [4.101]
    [4.3685]
    import Control.Lens
  • edit in lib/Quixotic/Database/SQLite.hs at line 8
    [4.3719]
    [4.3798]
    import Data.Text.Lens
  • edit in lib/Quixotic/Database/SQLite.hs at line 12
    [4.3837]
    [3.4]
    import Quixotic.Auction
  • edit in lib/Quixotic/Database/SQLite.hs at line 15
    [4.3901]
    [4.3922]
    import Quixotic.Users
  • replacement in lib/Quixotic/Database/SQLite.hs at line 23
    [3.187][3.187:330]()
    , newAuction = undefined
    , readAuction = undefined
    , recordBid = undefined
    , readBids = undefined
    , createUser = undefined
    [3.187]
    [3.330]
    , newAuction = newAuction'
    , readAuction = readAuction'
    , recordBid = recordBid'
    , readBids = readBids'
    , createUser = createUser'
  • replacement in lib/Quixotic/Database/SQLite.hs at line 34
    [3.505][3.505:544]()
    [ ("btcAddr", unpack (address ba))
    [3.505]
    [3.544]
    [ ("btcAddr", ba ^. address ^. from packed)
  • edit in lib/Quixotic/Database/SQLite.hs at line 44
    [15.96]
    [4.4555]
    newAuction' :: Auction -> ReaderT a (EitherT Text IO) AuctionId
    newAuction' = undefined
    readAuction' :: AuctionId -> ReaderT a (EitherT Text IO) Auction
    readAuction' = undefined
    recordBid' :: UTCTime -> Bid -> ReaderT a (EitherT Text IO) ()
    recordBid' = undefined
    readBids' :: AuctionId -> ReaderT a (EitherT Text IO) [(UTCTime, Bid)]
    readBids' = undefined
    createUser' :: User -> ReaderT a (EitherT Text IO) UserId
    createUser' = undefined
  • replacement in lib/Quixotic.hs at line 1
    [4.2457][4.1091:1126]()
    {-# LANGUAGE NoImplicitPrelude #-}
    [4.2457]
    [4.1126]
    {-# LANGUAGE NoImplicitPrelude, TemplateHaskell #-}
  • replacement in lib/Quixotic.hs at line 3
    [4.1127][4.5553:5569](),[4.2457][4.5553:5569](),[4.5569][4.2472:2493](),[4.2472][4.2472:2493](),[4.2493][4.1107:1124](),[4.1124][2.1257:1269](),[4.1124][4.2505:2515](),[2.1269][4.2505:2515](),[4.2505][4.2505:2515]()
    module Quixotic
    ( BtcAddr(address)
    , parseBtcAddr
    , BTC(..)
    ) where
    [4.1127]
    [4.2515]
    module Quixotic where
  • replacement in lib/Quixotic.hs at line 6
    [4.1149][4.1149:1150](),[4.1150][4.2516:2548](),[4.2516][4.2516:2548]()
    import qualified Data.Text as T
    [4.1149]
    [4.1739]
    import Control.Lens
  • replacement in lib/Quixotic.hs at line 11
    [4.2593][4.1125:1198]()
    newtype BtcAddr = BtcAddr { address :: T.Text } deriving (Show, Eq, Ord)
    [4.2593]
    [4.2661]
    newtype BtcAddr = BtcAddr { _address :: Text } deriving (Show, Eq, Ord)
    makeLenses ''BtcAddr
  • replacement in lib/Quixotic.hs at line 14
    [4.2662][2.1289:1354]()
    newtype BTC = BTC { runBTC :: Integer } deriving (Show, Eq, Ord)
    [4.2662]
    [2.1354]
    newtype BTC = BTC { _btc :: Integer } deriving (Show, Eq, Ord)
    makeLenses ''BTC
  • replacement in lib/Quixotic.hs at line 18
    [2.1384][2.1384:1427]()
    (<>) b1 b2 = BTC $ runBTC b1 + runBTC b2
    [2.1384]
    [2.1427]
    (<>) b1 b2 = BTC $ _btc b1 + _btc b2
  • replacement in lib/Quixotic.hs at line 25
    [2.1514][2.1514:1553]()
    invert b = BTC . negate . runBTC $ b
    [2.1514]
    [2.1553]
    invert b = BTC . negate . _btc $ b
  • replacement in lib/Quixotic.hs at line 29
    [2.1582][4.1199:1239](),[4.2662][4.1199:1239]()
    parseBtcAddr :: T.Text -> Maybe BtcAddr
    [2.1582]
    [4.1239]
    parseBtcAddr :: Text -> Maybe BtcAddr