aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2015-03-21 18:08:51 +0900
committerSean Whitton <spwhitton@spwhitton.name>2015-03-21 18:08:51 +0900
commitff061c40cd58cef6f84740c044dd9effcce5de37 (patch)
treec67781e7f5cabb8e074baaaca7ec8feebf324430
parentd789bb983b95941b5854b5980eded3208feb983a (diff)
downloadsariulclocks-ff061c40cd58cef6f84740c044dd9effcce5de37.tar.gz
comment out new monad: broken
-rw-r--r--sariulclocks.cabal2
-rw-r--r--src/Utils/ScoresFile.hs51
-rw-r--r--src/sariulccron.hs20
3 files changed, 40 insertions, 33 deletions
diff --git a/sariulclocks.cabal b/sariulclocks.cabal
index 4266dc6..bf2fe90 100644
--- a/sariulclocks.cabal
+++ b/sariulclocks.cabal
@@ -20,7 +20,7 @@ executable sariulclocks.cgi
main-is: sariulclocks.hs
-- other-modules:
-- other-extensions:
- build-depends: base, cgi, xhtml, time, directory, filepath, split, old-time, mtl, text
+ build-depends: base, cgi, xhtml, time, directory, filepath, split, old-time, mtl, text, boxes
hs-source-dirs: src
default-language: Haskell2010
ld-options: -static -pthread
diff --git a/src/Utils/ScoresFile.hs b/src/Utils/ScoresFile.hs
index eac386c..f981a4a 100644
--- a/src/Utils/ScoresFile.hs
+++ b/src/Utils/ScoresFile.hs
@@ -14,7 +14,7 @@ import Control.Monad (liftM)
import Data.List.Split (splitOn)
import Data.Maybe (fromJust)
import System.FilePath ((</>))
-import Control.Monad.SariulClocks
+-- import Control.Monad.SariulClocks
import Control.Monad.Trans (liftIO)
scoresToCSV :: ScoresList -> String
@@ -35,27 +35,30 @@ scoresFromCSV csv = foldr step [] (lines csv)
classString:scoreString:timeString:[] = splitOn "," line
theClass = fromJust $ lookupSariulClass ((read . (:[]) . head) classString) ((read . (:[]) . last) classString)
--- try to read from scores-XX.csv where XX is largest timestamp
-readScoresFile :: SariulScoresMonad a => a (Maybe ScoresList)
-readScoresFile = do
- curDir <- liftIO getCurrentDirectory
- let dataDir = curDir </> "data"
- filenames <- liftM (reverse . sort . filter isCSV) $ liftIO $ getDirectoryContents dataDir
- if null filenames
- then return Nothing
- else do
- -- let scores = liftM scoresFromCSV $ liftIO $ readFile (dataDir </> head filenames)
- scores <- liftIO $ scoresFromCSV <$> readFile (dataDir </> head filenames)
- putScores scores
- return $ Just scores
- where isCSV path = takeExtension path == ".csv"
+-- -- try to read from scores-XX.csv where XX is largest timestamp
+-- readScoresFile :: SariulScoresMonad a => a (Maybe ScoresList)
+-- readScoresFile = do
+-- curDir <- liftIO getCurrentDirectory
+-- let dataDir = curDir </> "data"
+-- filenames <- liftM (reverse . sort . filter isCSV) $ liftIO $ getDirectoryContents dataDir
+-- if null filenames
+-- then return Nothing
+-- else do
+-- -- let scores = liftM scoresFromCSV $ liftIO $ readFile (dataDir </> head filenames)
+-- scores <- liftIO $ scoresFromCSV <$> readFile (dataDir </> head filenames)
+-- putScores scores
+-- return $ Just scores
+-- where isCSV path = takeExtension path == ".csv"
--- writes to score-XX.csv where XX is unix timestamp: a simple-minded logging
-writeScoresFile :: SariulScoresMonad a => a ()
-writeScoresFile = do
- scores <- getScores
- curDir <- liftIO getCurrentDirectory
- let dataDir = curDir </> "data"
- timestamp <- liftM round $ liftIO getPOSIXTime
- let filename = dataDir </> ("scores-" ++ show timestamp ++ ".csv")
- liftIO $ writeFile filename (scoresToCSV scores)
+-- -- writes to score-XX.csv where XX is unix timestamp: a simple-minded logging
+-- writeScoresFile :: SariulScoresMonad a => a ()
+-- writeScoresFile = do
+-- scores <- getScores
+-- curDir <- liftIO getCurrentDirectory
+-- let dataDir = curDir </> "data"
+-- timestamp <- liftM round $ liftIO getPOSIXTime
+-- let filename = dataDir </> ("scores-" ++ show timestamp ++ ".csv")
+-- liftIO $ writeFile filename (scoresToCSV scores)
+
+readScoresFile = undefined
+writeScoresFile = undefined
diff --git a/src/sariulccron.hs b/src/sariulccron.hs
index fdaf61c..87b5e30 100644
--- a/src/sariulccron.hs
+++ b/src/sariulccron.hs
@@ -1,19 +1,23 @@
-import Control.Monad.SariulClocks
+-- import Control.Monad.SariulClocks
import Utils.ScoresFile
import Types.Scores
import Types.Classes
import Control.Monad (liftM, when)
+import Text.PrettyPrint.Boxes
+
+scoresBox :: ScoresList -> Box
+scoresBox = undefined
weeklyCron :: ScoresList -> ScoresList
weeklyCron scores = undefined
-main :: IO ()
-main = runSariulClocksIO $ do
- scores <- readScoresFile
- when (isJust scores) $ do
- modifyScores weeklyCron
- shouldModify <- liftM (((/=) scores) . Just) getScores
- when shouldModify writeScoresFile
+-- main :: IO ()
+-- main = runSariulClocksIO $ do
+-- scores <- readScoresFile
+-- when (isJust scores) $ do
+-- modifyScores weeklyCron
+-- shouldModify <- liftM (((/=) scores) . Just) getScores
+-- when shouldModify writeScoresFile
isJust :: Maybe a -> Bool
isJust (Just _) = True