forked from smallhadroncollider/taskell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16c9d02
commit 292b6b0
Showing
12 changed files
with
146 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Data.Taskell.AllTasks where | ||
|
||
import Data.Map.Strict (Map, fromList) | ||
import Data.Taskell.Tasks (Tasks, empty) | ||
|
||
type AllTasks = Map String Tasks | ||
|
||
initial :: AllTasks | ||
initial = fromList [("To Do", empty), ("Done", empty)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Data.Taskell.Tasks where | ||
|
||
import Data.Maybe (fromMaybe) | ||
import Prelude hiding (splitAt, drop) | ||
import Data.Sequence (Seq, (><), (|>), (!?), fromList, insertAt, deleteAt, splitAt, drop) | ||
|
||
import Data.Taskell.Task (Task) | ||
|
||
type Tasks = Seq Task | ||
|
||
empty :: Tasks | ||
empty = fromList [] | ||
|
||
extract :: Int -> Tasks -> Maybe (Tasks, Task) | ||
extract i ts = do | ||
c <- ts !? i | ||
let a = deleteAt i ts | ||
return (a, c) | ||
|
||
update' :: Int -> (Task -> Task) -> Tasks -> Maybe Tasks | ||
update' i fn ts = do | ||
let (a, b) = splitAt i ts | ||
current <- b !? 0 | ||
let b' = drop 1 b | ||
return ((a |> fn current) >< b') | ||
|
||
update :: Int -> (Task -> Task) -> Tasks -> Tasks | ||
update i fn ts = fromMaybe ts (update' i fn ts) | ||
|
||
move' :: Int -> Int -> Tasks -> Maybe Tasks | ||
move' from dir ts = do | ||
current <- ts !? from | ||
let r = deleteAt from ts | ||
return (insertAt (from + dir) current r) | ||
|
||
move :: Int -> Int -> Tasks -> Tasks | ||
move from dir ts = fromMaybe ts (move' from dir ts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.