aboutsummaryrefslogtreecommitdiffstats
path: root/src/Plugin.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Plugin.hs')
-rw-r--r--src/Plugin.hs18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/Plugin.hs b/src/Plugin.hs
index e25a1dc..2a06fb4 100644
--- a/src/Plugin.hs
+++ b/src/Plugin.hs
@@ -1,6 +1,6 @@
module Plugin
- ( realMatchPlugin
- , Plugin
+ ( Plugin
+ , matchPlugin
, performPlugin
, plugins
) where
@@ -15,19 +15,15 @@ data Plugin = Plugin
instance Show Plugin where
show (Plugin r p) = "matchRegex = " ++ r
-realMatchPlugin :: String -> Maybe Plugin
-realMatchPlugin message = matchPlugin message plugins
-
-matchPlugin :: String -> [Plugin] -> Maybe Plugin
-matchPlugin message plugins = firstPlugin $ matchPlugins message plugins
+matchPlugin :: String -> Maybe Plugin
+matchPlugin message = firstPlugin $ matchPlugins message plugins
+ where
+ firstPlugin [] = Nothing
+ firstPlugin (p:ps) = Just p
matchPlugins :: String -> [Plugin] -> [Plugin]
matchPlugins message plugins = [p | p <- plugins, message =~ matchRegex p]
-firstPlugin :: [Plugin] -> Maybe Plugin
-firstPlugin [] = Nothing
-firstPlugin (p:ps) = Just p
-
-- TODO: Make a type for the `perform` function
performPlugin :: Plugin -> String -> String
performPlugin p message = perform p $ message =~ matchRegex p