packages feed

rasa-ext-cmd 0.1.2 → 0.1.3

raw patch · 2 files changed

+14/−17 lines, 2 filesdep ~rasa

Dependency ranges changed: rasa

Files

rasa-ext-cmd.cabal view
@@ -1,5 +1,5 @@ name: rasa-ext-cmd-version: 0.1.2+version: 0.1.3 cabal-version: >=1.10 build-type: Simple license: GPL-3@@ -22,7 +22,7 @@         Rasa.Ext.Cmd     build-depends:         base >=4.8 && <5,-        rasa >=0.1.9 && <0.2,+        rasa >=0.1.11 && <0.2,         data-default >=0.7.1.1 && <0.8,         lens ==4.14.*,         text >=1.2.2.1 && <1.3,
src/Rasa/Ext/Cmd.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE TemplateHaskell #-}- module Rasa.Ext.Cmd   ( addCmd   , runCmd@@ -12,28 +10,27 @@ import Data.Default import Data.Typeable -data Cmd = Cmd-  { _commands :: Map String (String -> Action ())-  } deriving (Typeable)+data Cmd =+  Cmd (Map String (String -> App ()))+  deriving (Typeable)  instance Show Cmd where   show (Cmd cmds) = show (keys cmds) -makeLenses ''Cmd- instance Default Cmd where-  def = Cmd-    { _commands=empty-    }+  def = Cmd empty  -- It would be nice to make this a little more generic, but I'm not sure how right now.--- TODO try switching to T.Text -> (T.Text -> a) -> Action ()-addCmd :: String -> (String -> Action ()) -> Action ()-addCmd alias mkEvent = ext.commands.at alias ?= mkEvent+-- TODO try switching to T.Text -> (T.Text -> a) -> App ()+addCmd :: String -> (String -> App ()) -> App ()+addCmd alias mkEvent =+  stateLens %= add+    where add (Cmd commands) = Cmd $ commands & at alias ?~ mkEvent -runCmd :: String -> String -> Action ()+runCmd :: String -> String -> App () runCmd alias args = do-  mCmd <- use (ext.commands.at alias)+  Cmd commands <- use stateLens+  let mCmd = commands^.at alias   case mCmd of     Just cmd -> cmd args     Nothing -> return ()