packages feed

AAI 0.1.0.0 → 0.2.0.0

raw patch · 4 files changed

+19/−20 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Control.Router: type ErrorHandler = String -> IO ()
- Control.Command: help :: Command a => a -> [String] -> IO ()
+ Control.Command: help :: Command a => a -> String
- Control.Router: route :: (Command a, Router a) => ErrorHandler -> [a] -> [String] -> IO ()
+ Control.Router: route :: (Command a, Router a, Alternative m, Monad m) => [a] -> String -> m a

Files

AAI.cabal view
@@ -1,5 +1,5 @@ name:                   AAI-version:                0.1.0.0+version:                0.2.0.0 synopsis:               Abstract Application Interface. description:            The Abstract Application Interface is used to define a                         generic interface for handling command line parameter@@ -14,6 +14,7 @@ build-type:             Simple extra-source-files:     README.md                   ,     LICENSE+                  ,     changelog.md cabal-version:          >=1.10  source-repository head@@ -23,7 +24,7 @@ source-repository this   type:                 git   location:             https://github.com/aka-bash0r/AAI-  tag:                  v0.1.0.0+  tag:                  v0.2.0.0  library   exposed-modules:      Control.Command@@ -31,3 +32,4 @@   build-depends:        base >=4.8 && <4.9   hs-source-dirs:       src   default-language:     Haskell2010+
+ changelog.md view
@@ -0,0 +1,9 @@+# Changelog++## v0.2.0.0+* Changed the interface of help from Command type class.+* Changed routing mechanism to not execute immediately.++## v0.1.0.0+Initial release of the AAI.+
src/Control/Command.hs view
@@ -21,5 +21,5 @@     -- | Execute a command.     execute :: a -> [String] -> IO ()     -- | Execute the help of a command.-    help    :: a -> [String] -> IO ()+    help    :: a -> String 
src/Control/Router.hs view
@@ -13,7 +13,6 @@ -} module Control.Router ( Router (..)-, ErrorHandler , route ) where @@ -26,21 +25,10 @@     -- | Checks if a command is routable to a specific command name.     routes :: a -> String -> Bool --- | A simple error handling function.-type ErrorHandler = String -> IO ()- -- | Route a specific instruction to a command.-route :: (Command a, Router a) => ErrorHandler -> [a] -> [String] -> IO ()-route eh cmds []         = eh "Empty argument list. Cannot route command."-route eh cmds (cmd:args) =-    case findCommand cmd cmds of-      Just a  -> execute a args-      Nothing -> eh ("Command " ++ cmd ++ " is unknown.")-  where-    findCommand _   []     =-      empty-    findCommand cmd (x:xs) =-      if routes x cmd-         then return x-         else findCommand cmd xs+route :: (Command a, Router a, Alternative m, Monad m) => [a] -> String -> m a+route (x:xs) cmd =+    if routes x cmd+       then return x+       else route xs cmd