Initial compilation of payouts function succeeds.
[?]
Feb 28, 2014, 5:08 AM
4QX5E5ACVN57KJLCWOM4JEI6JSV4XZNCWVYPOTKSOMUW3SOMCNJACDependencies
- [2]
N4NDAZYTInitial implementation of payouts. - [3]
EQXRXRZDChanged to use tasty instead of test-framework - [4]
7DBNV3GVInitial, stack-based impl of time log event reduction. - [5]
JUUMYIQEAdd groupBy utility function for use in TimeLog. - [6]
NVOCQVASInitial failing tests.
Change contents
- replacement in src/Ananke/TimeLog.hs at line 1
{-# LANGUAGE DeriveDataTypeable #-}{-# LANGUAGE DeriveDataTypeable, ScopedTypeVariables #-} - edit in src/Ananke/TimeLog.hs at line 49
type NDT = NominalDiffTime - replacement in src/Ananke/TimeLog.hs at line 51
sumLogIntervals :: [LogInterval] -> RationalsumLogIntervals ivals = F.foldl' (+) (fromInteger 0) $ fmap (toRational . ilen . workInterval) ivals{-|The depreciation function should return a value between 0 and 1;this result is multiplied by the length of an interval of work to determinethe depreciated value of the work.-}newtype Depreciation = Depreciation { depf :: NDT -> Rational } - replacement in src/Ananke/TimeLog.hs at line 58
payouts :: WorkIndex -> Payoutspayouts widx = let addIntervalDiff total ivals = (\dt -> (dt + total, dt)) $ sumLogIntervals ivals(totalTime, keyTimes) = M.mapAccum addIntervalDiff (fromInteger 0) $ M.map snd widxin M.map (\kt -> kt / totalTime) keyTimes{-|Payouts are determined by computing a depreciated duration value foreach work interval. This function computes the percentage of the totalwork allocated to each address.-}payouts :: Depreciation -> UTCTime -> WorkIndex -> Payoutspayouts dep ptime widx = let addIntervalDiff :: (Functor f, Foldable f) => NDT -> f LogInterval -> (NDT, NDT)addIntervalDiff total ivals = (\dt -> (dt + total, dt)) $ sumLogIntervals dep ptime ivals(totalTime, keyTimes) = M.mapAccum addIntervalDiff (fromInteger 0) $ M.map snd widxin M.map (\kt -> toRational $ kt / totalTime) keyTimes{-|-}sumLogIntervals :: (Functor f, Foldable f) => Depreciation -> UTCTime -> f LogInterval -> NDTsumLogIntervals dep ptime ivals = F.foldl' (+) (fromInteger 0) $ fmap (depreciateInterval dep ptime) ivals - edit in src/Ananke/TimeLog.hs at line 75
depreciateInterval :: Depreciation -> UTCTime -> LogInterval -> NDTdepreciateInterval dep ptime ival = let depreciation :: Rationaldepreciation = depf dep $ diffUTCTime ptime (end . workInterval $ ival)in fromRational $ depreciation * (toRational . ilen . workInterval $ ival)