packages feed

hatt 1.3.0 → 1.3.1

raw patch · 3 files changed

+48/−66 lines, 3 filesdep +haskelinePVP ok

version bump matches the API change (PVP)

Dependencies added: haskeline

API changes (from Hackage documentation)

Files

README.md view
@@ -45,51 +45,30 @@      $ hatt     Entering interactive mode. Type `help` if you don't know what to do!-    > help-    Hatt's interactive mode has several commands.-    -    help-      Print this help text.-    -    pretty-      Pretty-print expressions using Unicode logic symbols. Only employ this-      option if your console is Unicode-aware. If pretty-printing is already-      enabled, using this command will disable it.-    -    colour-      Colour truth values: green for true, red for false. This feature needs-      your console to support ANSI colour codes. If coloured mode is already-      enabled, this command will disable it.-    -    exit-      Quit the program.-    -    If you don't type in a command, the program will assume you're writing a-    logical expression to be evaluated and attempt to parse it.-    -    For example, if you enter "(A -> B)" at the prompt, Hatt will print the-    truth table for that expression. Here's an example console session.-    -        > (A | B)-        A B | (A | B)-        --------------        T T | F-        T F | T-        F T | T-        F F | F-        > foobar-        Parse error at (line 1, column 2):-        unexpected "o"-        expecting white space or end of input-        > exit-    -    If none of this makes any sense, try reading the README file.-    > (A -> B)-    A B | (A -> B)-    --------------+    > (A | B)+    A B | (A | B)+    -------------     T T | T-    T F | F+    T F | T     F T | T+    F F | F+    > (p -> (q & ~r))+    p q r | (p -> (q & ~r))+    -----------------------+    T T T | F+    T T F | T+    T F T | F+    T F F | F+    F T T | T+    F T F | T+    F F T | T+    F F F | T+    > (e <-> f)+    e f | (e <-> f)+    ---------------+    T T | T+    T F | F+    F T | F     F F | T     > exit 
hatt.cabal view
@@ -1,5 +1,5 @@ Name:               hatt-Version:            1.3.0+Version:            1.3.1  Synopsis:           A truth table generator for classical propositional logic. Description:        Hatt is a command-line program which prints truth tables@@ -42,4 +42,5 @@                     cmdargs        >= 0.7,                     containers     >= 0.3 && < 0.5,                     parsec         >= 2.1 && < 2.2,-                    ansi-wl-pprint >= 0.6 && < 0.7+                    ansi-wl-pprint >= 0.6 && < 0.7,+                    haskeline      >= 0.6 && < 0.7
src/hatt.hs view
@@ -8,7 +8,7 @@ import Control.Monad (when, unless) import Data.Char (isSpace, toLower) import System.Console.CmdArgs-import System.IO+import System.Console.Haskeline (InputT, runInputT, defaultSettings, getInputLine, outputStr, outputStrLn)  data Command = Exit              | Help@@ -31,7 +31,7 @@   , interactive = False &= help "Enter interactive mode"   , pretty      = False &= help "Use Unicode logic symbols"   , coloured    = False &= help "Use colour-coded symbols"-  } &= summary "Hatt 1.3.0, (c) Benedict Eastaugh 2011"+  } &= summary "Hatt 1.3.1, (c) Benedict Eastaugh 2011"     &= program "hatt"  main :: IO ()@@ -49,24 +49,26 @@           -- interactive mode is NOT explicitly requested, terminate the           -- program; otherwise, enter interactive mode.           unless (evalMode && not interMode) $-              putStrLn replIntroText >> repl opts+              putStrLn replIntroText+              >> runInputT defaultSettings (repl opts) -repl :: ProgramMode -> IO ()-repl mode = do putStr "> "-               hFlush stdout-               cmd <- getLine-               case parseCommand cmd of-                 Exit        -> return ()-                 Help        -> putStr (replHelpText printer)-                                >> repl mode-                 Pretty      -> putStrLn ppMessage-                                >> repl (mode {pretty = not isPretty})-                 Coloured    -> putStrLn cpMessage-                                >> repl (mode {coloured = not isColoured})-                 (Eval expr) -> putStr (truthTableP printer expr)-                                >> repl mode-                 (Error err) -> putStrLn ("Error: " ++ err)-                                >> repl mode+repl :: ProgramMode -> InputT IO ()+repl mode = do+    minput <- getInputLine "> "+    case minput of+      Nothing  -> return ()+      Just cmd -> case parseCommand cmd of+        Exit        -> return ()+        Help        -> outputStr (replHelpText printer)+                       >> repl mode+        Pretty      -> outputStrLn ppMessage+                       >> repl (mode {pretty = not isPretty})+        Coloured    -> outputStrLn cpMessage+                       >> repl (mode {coloured = not isColoured})+        (Eval expr) -> outputStr (truthTableP printer expr)+                       >> repl mode+        (Error err) -> outputStrLn ("Error: " ++ err)+                       >> repl mode   where     printer    = selectPrinter mode     isPretty   = pretty mode@@ -128,8 +130,8 @@   , ""   , "    > (A | B)"   , indentBy 4 $ truthTableP printer (Disjunction (Variable "A") (Variable "B"))- ++ "> foobar\n"- ++ eval printer "foobar"+ ++ "> (A -> B)\n"+ ++ truthTableP printer (Conditional (Variable "A") (Variable "B"))  ++ "> exit"   , "If none of this makes any sense, try reading the README file."   ]