clanki 1.0.6 → 1.0.7
raw patch · 4 files changed
+26/−10 lines, 4 files
Files
- clanki.cabal +1/−1
- src/Add.hs +5/−2
- src/Quiz.hs +17/−6
- src/Remove.hs +3/−1
clanki.cabal view
@@ -2,7 +2,7 @@ -- see http://haskell.org/cabal/users-guide/ name: clanki-version: 1.0.6+version: 1.0.7 synopsis: Command-line spaced-repetition software description: Command-line spaced-repetition learning software. CL (command line) + Anki (popular spaced-repetition software) = Clanki. Usage is fairly simple, just follow the instructions after running the program. Add a deck, add cards to the deck, then quiz whenever possible. The program will determine what cards need to be reviewed, using the Super Memo 2 algorithm. license: MIT
src/Add.hs view
@@ -7,7 +7,8 @@ data AddAction = NewDeck | ToDeck deriving (Show, Eq) instance Display AddAction where- display = show+ display NewDeck = "New deck"+ display ToDeck = "Add to deck" addLoop :: [Deck] -> IO [Deck] addLoop decks = do@@ -68,7 +69,9 @@ getAddAction :: [Deck] -> IO (Maybe AddAction) getAddAction [] = return $ Just NewDeck-getAddAction _ = Input.getUserChoice allAddActions+getAddAction _ = do+ printf $ "What would you like to do?" ++ "\n"+ Input.getUserChoice allAddActions allAddActions :: [AddAction] allAddActions = [NewDeck, ToDeck]
src/Quiz.hs view
@@ -7,6 +7,7 @@ import Safe(readMay) import Data.Time.Clock.POSIX import qualified Input+import Control.Monad(filterM) data QuizAction = AllCards | FromDeck deriving (Show, Eq) allQuizActions :: [QuizAction]@@ -45,6 +46,10 @@ maybeQuiz :: Card -> IO Card maybeQuiz card = shouldQuizCard card >>= (\shouldQuiz -> if shouldQuiz then quizCard card else return card)++cardsToQuiz :: [Deck] -> IO [Card]+cardsToQuiz decks = filterM shouldQuizCard cards+ where cards = allCards decks {-quizCards :: [Card] -> [Deck] -> IO [Deck]-}@@ -76,13 +81,19 @@ Just confidence -> if confidence `elem` [1 .. 5] then return confidence else getAnswerConfidence Nothing -> getAnswerConfidence --- quizFromDeck :: Deck -> [Deck] -> IO [Deck] quizFromDeck deck decks = quizDeck deck >>= (\newDeck -> return $ replaceDeckNamed (dName deck) newDeck decks) getQuizAction :: [Deck] -> IO (Maybe QuizAction)-getQuizAction decks = Input.getUserChoice allQuizActions- -+getQuizAction [] = do+ printf $ "No decks, returning to menu" ++ "\n"+ return Nothing+getQuizAction decks = do+ cardsToBeQuizzed <- cardsToQuiz decks+ case cardsToBeQuizzed of+ [] -> do+ printf $ "No cards need to be quizzed at this time" ++ "\n" + return Nothing+ _ -> do+ printf $ "What would you like to be quizzed on?" ++ "\n"+ Input.getUserChoice allQuizActions
src/Remove.hs view
@@ -51,7 +51,9 @@ getRemoveAction [] = return Nothing getRemoveAction decks | all (null . dCards) decks = return $ Just RemoveDeck- | otherwise = Input.getUserChoice allRemoveActions+ | otherwise = do+ printf $ "What would you like to do?" ++ "\n"+ Input.getUserChoice allRemoveActions allRemoveActions :: [RemoveAction] allRemoveActions = [RemoveDeck, RemoveFromDeck]