clanki 1.2.0 → 1.2.1
raw patch · 2 files changed
+12/−9 lines, 2 filesdep +bytestringdep +strict
Dependencies added: bytestring, strict
Files
- clanki.cabal +2/−2
- src/Main.hs +10/−7
clanki.cabal view
@@ -2,7 +2,7 @@ -- see http://haskell.org/cabal/users-guide/ name: clanki-version: 1.2.0+version: 1.2.1 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@@ -22,6 +22,6 @@ main-is: Main.hs other-modules: Add, Quiz, Remove, Display, Card, Input, Tracker, StatTracker -- other-extensions: - build-depends: base >=4.6 && <4.8, time >= 1.4.2, directory >= 1.2.1.0, safe+ build-depends: base >=4.6 && <4.8, time >= 1.4.2, directory >= 1.2.1.0, safe, bytestring, strict hs-source-dirs: src default-language: Haskell2010
src/Main.hs view
@@ -1,5 +1,4 @@ module Main where-{-import Decks-} import Add import Input import Remove@@ -13,18 +12,19 @@ import Data.Maybe(isJust) import Safe(readMay) import Control.Monad(filterM)+import qualified System.IO.Strict as SIO+import qualified Data.ByteString as Str data Action = Quiz | Add | Remove | Show | Quit deriving (Show, Eq, Ord, Enum) instance Display Action where- display act = show act+ display = show allActions :: [Action] allActions = [Quiz ..] getAction :: IO (Maybe Action)-getAction = do- Input.getUserChoice allActions+getAction = Input.getUserChoice allActions runAction :: Maybe Action -> [Card] -> IO () runAction (Just Quit) cards = do@@ -40,6 +40,9 @@ printf $ "Invalid input" ++ "\n" mainLoop cards +{-fileHandle :: IO Handle-}+{-fileHandle = openFile "data.clanki" ReadWriteMode-}+ fileName :: String fileName = "data.clanki" @@ -53,8 +56,8 @@ fileExists <- doesFileExist fileName if fileExists then do- x <- readFile fileName- return (read x :: [Card])+ x <- SIO.readFile fileName+ return $ read x else return [] @@ -79,7 +82,7 @@ | firstOptionIsNum = do let numOfCardsToQuiz = read (head args) :: Int quizSomeCards (take numOfCardsToQuiz cards) cards- | firstOptionIsDeck = do+ | firstOptionIsDeck = if secondOptionIsNum then do let numOfCardsToQuiz = read $ args !! 1