diff options
| author | Teddy Wing | 2017-07-30 19:07:11 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-07-30 19:07:11 +0200 | 
| commit | 487f8f805647d3f3fbb86aac6838f0c0e37a6bde (patch) | |
| tree | bf9e1cc50172df56f59adb1585e752c7c8ee166d /src | |
| parent | b4802d1f1fa4f97ff5613c79398c204ebdfcbd75 (diff) | |
| download | sorbot-487f8f805647d3f3fbb86aac6838f0c0e37a6bde.tar.bz2 | |
Add a type for plugin actions
Instead of implicitly using `String -> String` as the type for plugin
action/perform functions, create a real type to represent this.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Plugin.hs | 7 | 
1 files changed, 4 insertions, 3 deletions
| diff --git a/src/Plugin.hs b/src/Plugin.hs index 2a06fb4..6522e0b 100644 --- a/src/Plugin.hs +++ b/src/Plugin.hs @@ -7,9 +7,11 @@ module Plugin  import Text.Regex.TDFA +type PluginAction = String -> String +  data Plugin = Plugin      { matchRegex :: String -    , perform    :: String -> String +    , perform    :: PluginAction      }  instance Show Plugin where @@ -24,7 +26,6 @@ matchPlugin message = firstPlugin $ matchPlugins message plugins  matchPlugins :: String -> [Plugin] -> [Plugin]  matchPlugins message plugins = [p | p <- plugins, message =~ matchRegex p] --- TODO: Make a type for the `perform` function  performPlugin :: Plugin -> String -> String  performPlugin p message = perform p $ message =~ matchRegex p @@ -33,7 +34,7 @@ gitHubCommit = Plugin      , perform = gitHubCommitAction      } -gitHubCommitAction :: String -> String +gitHubCommitAction :: PluginAction  gitHubCommitAction match = "https://github.com/" ++ match  plugins :: [Plugin] | 
