Commit f1e287f3 authored by MrMan's avatar MrMan

Add some structure for components to use

parent f7cacb89
......@@ -185,3 +185,24 @@ instance Validatable (PartialTask state) where
where
notEmptyIfPresent :: DT.Text -> Maybe ValidationError
notEmptyIfPresent v = if DT.null v then Just (InvalidField taskDescField) else Nothing
----------------
-- Components --
----------------
class Component c where
start :: c -> IO ()
stop :: c -> IO ()
data TaskStoreError = NoSuchTask TaskID
| UnexpectedError DT.Text
deriving (Eq, Show, Read)
newtype TaskID = TaskID { getTaskID :: Int } deriving (Eq, Show, Read)
class Component c => TaskStore c where
persistTask :: c -> Validated (FullySpecifiedTask state) -> Either TaskStoreError (FullySpecifiedTask state)
completeTask :: c -> TaskID -> Either TaskStoreError CompletedTask
getTask :: c -> TaskID -> Either TaskStoreError (FullySpecifiedTask state)
updateTask :: c -> TaskID -> PartialTask state -> Either TaskStoreError (FullySpecifiedTask state)
deleteTask :: c -> TaskID -> Either TaskStoreError (FullySpecifiedTask state)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment