packages feed

clanki (empty) → 1.0.0

raw patch · 4 files changed

+114/−0 lines, 4 filesdep +basedep +directorydep +safesetup-changed

Dependencies added: base, directory, safe, time

Files

+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2014 Marcus Buffett++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ clanki.cabal view
@@ -0,0 +1,24 @@+-- Initial clanki.cabal generated by cabal init.  For further documentation,+--  see http://haskell.org/cabal/users-guide/++name:                clanki+version:             1.0.0+synopsis:            Command-line spaced-repetition learning software. CL (command line) + Anki (popular spaced-repetition software) = Clanki.+description:         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+license-file:        LICENSE+author:              Marcus Buffett+maintainer:          marcusbuffett@me.com+-- copyright:           +category:            Education+build-type:          Simple+-- extra-source-files:  +cabal-version:       >=1.10++executable clanki+  main-is:             Main.hs+  -- other-modules:       +  -- other-extensions:    +  build-depends:       base >=4.7 && <4.8, time >= 1.4.2, directory >= 1.2.1.0, safe+  hs-source-dirs:      src+  default-language:    Haskell2010
+ src/Main.hs view
@@ -0,0 +1,68 @@+module Main where+import Decks+import Add+import Input+import Remove+import Quiz+import Text.Printf(printf)+import System.Directory(doesFileExist)++import Display+data Action = Quiz | Add | Remove | Quit {--| Show --}  deriving (Show, Eq, Ord, Enum)++instance Display Action where+    display act = show act++allActions :: [Action]+allActions = [Quiz ..]++getAction :: IO (Maybe Action)+getAction = do+    Input.getUserChoice allActions++runAction :: Maybe Action -> [Deck] -> IO [Deck]+runAction action decks= case action of +    Just Quit   -> return decks+    Just Add    -> addLoop decks   >>= mainLoop+    Just Quiz   -> quizLoop decks  >>= mainLoop+    Just Remove -> removeLoop decks >>= mainLoop+    {-Just Show   -> do-}+        {-showDecks decks -}+        {-mainLoop decks-}+    Nothing     -> do+        printf $ "Invalid input" ++ "\n"+        mainLoop decks++{-showDecks decks = printf $ unlines $ map display decks-}++fileName :: String+fileName = "data.clanki"+++mainLoop :: [Deck] -> IO [Deck]+mainLoop decks = do+    action <- getAction+    runAction action decks+++loadData :: IO [Deck]+loadData = do+    fileExists <- doesFileExist fileName+    if fileExists+        then do+        x <- readFile fileName+        return (read x :: [Deck])+        else return $ []+++saveData :: [Deck] -> IO ()+saveData decks = writeFile fileName (show decks)+++main :: IO ()+main = do+    decks <- loadData+    newDecks <- mainLoop decks+    saveData newDecks+    return ()+