-
Notifications
You must be signed in to change notification settings - Fork 0
/
Model.hs
34 lines (23 loc) · 1 KB
/
Model.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{-# LANGUAGE QuasiQuotes, TypeFamilies, GeneralizedNewtypeDeriving, TemplateHaskell, GADTs, OverloadedStrings #-}
module Model where
import Yesod
import Data.String (IsString)
import Data.Text (Text)
import Text.Blaze (ToHtml)
-- You can define all of your database entities in the entities file.
-- You can find more information on persistent and how to declare entities
-- at:
-- http://www.yesodweb.com/book/persistent/
share [mkPersist sqlSettings, mkMigrate "migrateAll"] $(persistFile "config/models")
newtype TaskState = TaskState Text
deriving (ToHtml, IsString)
data NewTask = NewTask { newTaskTitle :: Text } deriving (Show)
newTask :: UserId -> NewTask -> Task
newTask uid (NewTask title) = Task uid title 0 False
taskState :: Task -> TaskState
taskState task = if taskDone task then "done" else "pending"
taskActionName :: Task -> Text
taskActionName task | taskDone task = "Restart"
| otherwise = "Complete"
estimateOptions :: [Int]
estimateOptions = [2 ^ x | x <- [0 .. 4]]