Make project compile again

This commit also adds a few other files that I've been working on,
although most of it will get deleted again. This is just so I have them
logged in git.
This commit is contained in:
Joscha 2018-04-04 22:18:04 +00:00
parent 2da41951e1
commit bff0656806
7 changed files with 180 additions and 21 deletions

93
src/TaskMachine/Task.hs Normal file
View file

@ -0,0 +1,93 @@
{-# LANGUAGE RecordWildCards #-}
-- | Task related stuff.
--
-- This module will be used by both the UI and the database modules.
-- It contains some functionality independent of any of those modules.
--
-- (Although I don't really know what exactly that will be.)
module TaskMachine.Task
( Task(..)
, Subtask(..)
) where
import qualified Data.Text as T
import qualified TaskMachine.DateExpr as TM
import qualified TaskMachine.Deadline as TM
type SubtaskID = Integer
data Subtask = Subtask
{ subID :: SubtaskID
, subLabel :: T.Text
, subRepetitionsTotal :: Integer
, subRepetitionsDone :: Integer
}
type TaskID = Integer
data Task = Task
{ taskID :: TaskID
, taskDeadlines :: [TM.Deadline]
, taskFormula :: Maybe TM.IntExpr
, taskDescription :: T.Text
, taskDetails :: T.Text
, taskSubtasks :: [Subtask]
}
{-
( Task(..)
, Deadline(..)
, fromTaskRow
, toTaskRow
) where
import qualified Data.Text as T
import Data.Time.Calendar
import qualified TaskMachine.Database as TM
data Task = Task
{ taskID :: TM.TaskID
, taskDeadline :: Deadline
, taskIntFormula :: Maybe TM.IntFormula
, taskDescription :: T.Text
, taskDetails :: T.Text
, taskRepetitionsTotal :: Integer
, taskRepetitionsDone :: Integer
}
data Deadline
= DeadlineNone
| DeadlineDay Day (Maybe TM.Duration)
| DeadlineFormula TM.BoolFormula TM.Duration
getDeadline :: TM.TaskRow -> Deadline
getDeadline row = case TM.rowBoolFormula row of
Just formula -> DeadlineFormula formula $ fromMaybe 1 $ TM.rowDuration row
Nothing -> case TM.rowDeadline row of
Just day -> DeadlineDay day $ TM.rowDuration row
Nothing -> DeadlineNone
fromTaskRow :: TM.TaskRow -> Task
fromTaskRow row =
let taskID = TM.rowID row
taskDeadline = getDeadline row
taskIntFormula = TM.rowIntFormula row
taskDescription = TM.rowDescription row
taskDetails = TM.rowDetails row
taskRepetitionsTotal = TM.rowRepetitionsTotal
taskRepetitionsDone = TM.rowRepetitionsDone
in Task{..}
toTaskRow :: Task -> TM.TaskRow
toTaskRow task = undefined task
nextDeadline :: Day -> Deadline -> Maybe Day
updateDeadline (DeadlineFormula formula duration) =
let expr = boolFormulaExpr formula
in Just $ TM.findNext expr day duration
updateDeadline _ = Nothing
-}