Reverse ordering of completed tasks
This commit is contained in:
parent
3e0a9d34f7
commit
bac45278fe
2 changed files with 17 additions and 10 deletions
|
|
@ -333,19 +333,26 @@ emptyTask = Task Incomplete Nothing Nothing Nothing []
|
|||
newTask :: Day -> Task
|
||||
newTask day = Task Incomplete Nothing Nothing (Just day) []
|
||||
|
||||
-- Inverted compare for Maybes: Nothing comes after Just
|
||||
compareMaybe :: Ord a => Maybe a -> Maybe a -> Ordering
|
||||
compareMaybe Nothing Nothing = EQ
|
||||
compareMaybe (Just _) Nothing = LT
|
||||
compareMaybe Nothing (Just _) = GT
|
||||
compareMaybe (Just x) (Just y) = compare x y
|
||||
|
||||
compareDescription :: Description -> Description -> Ordering
|
||||
compareDescription = compare `on` formatDescription
|
||||
|
||||
compareTasks :: Task -> Task -> Ordering
|
||||
compareTasks a@(Task (Complete _) _ _ _ _) b@(Task (Complete _) _ _ _ _) = mconcat
|
||||
[ compare (taskCompletion b) (taskCompletion a)
|
||||
, compareMaybe (taskPriority a) (taskPriority b)
|
||||
, compareMaybe (taskDue a) (taskDue b)
|
||||
, compareDescription (taskDescription a) (taskDescription b)
|
||||
]
|
||||
compareTasks a b = mconcat
|
||||
[ compare (taskCompletion a) (taskCompletion b)
|
||||
, compareMaybe (taskPriority a) (taskPriority b)
|
||||
, compareMaybe (taskDue a) (taskDue b)
|
||||
, compareDescription (taskDescription a) (taskDescription b)
|
||||
]
|
||||
where
|
||||
-- Inverted compare for Maybes: Nothing comes after Just
|
||||
compareMaybe :: Ord a => Maybe a -> Maybe a -> Ordering
|
||||
compareMaybe Nothing Nothing = EQ
|
||||
compareMaybe (Just _) Nothing = LT
|
||||
compareMaybe Nothing (Just _) = GT
|
||||
compareMaybe (Just x) (Just y) = compare x y
|
||||
compareDescription :: Description -> Description -> Ordering
|
||||
compareDescription = compare `on` formatDescription
|
||||
|
|
|
|||
2
todo.txt
2
todo.txt
|
|
@ -12,4 +12,4 @@ x2018-09-30 c2018-09-30 Custom exception messages
|
|||
x2018-10-24 c2018-10-23 Don't crash on parse errors etc.
|
||||
- c2018-10-24 Add "u" - undo and "z" - redo buttons
|
||||
- c2018-10-24 Redo coloring - maybe black-on-white color scheme in-editor?
|
||||
- c2018-10-24 Reverse ordering of completed tasks - most recent at the top
|
||||
x2018-10-24 c2018-10-24 Reverse ordering of completed tasks - most recent at the top
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue