aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2017-07-30 19:36:28 +0200
committerTeddy Wing2017-07-30 19:36:28 +0200
commite4b00259ec4c1338f766561aba3b7a3a3159d216 (patch)
tree8ea8a29c3de9268d114041fc636354b1b8820ea7 /src
parent487f8f805647d3f3fbb86aac6838f0c0e37a6bde (diff)
downloadsorbot-e4b00259ec4c1338f766561aba3b7a3a3159d216.tar.bz2
Move `Plugin` and `PluginAction` to a new module
Move our base plugin types to a new module to enable us to use them in both the plugin matching code (which we'll leave in "Plugin.hs") and in specialised plugin modules. This enables us to import and provide a list of plugins in `plugins` in "Plugin.hs" and use these types in that file and in the plugin files without any circular/recursive module dependencies.
Diffstat (limited to 'src')
-rw-r--r--src/Plugin.hs13
-rw-r--r--src/Plugin/Base.hs17
2 files changed, 19 insertions, 11 deletions
diff --git a/src/Plugin.hs b/src/Plugin.hs
index 6522e0b..41b0296 100644
--- a/src/Plugin.hs
+++ b/src/Plugin.hs
@@ -1,21 +1,12 @@
module Plugin
- ( Plugin
- , matchPlugin
+ ( matchPlugin
, performPlugin
, plugins
) where
import Text.Regex.TDFA
-type PluginAction = String -> String
-
-data Plugin = Plugin
- { matchRegex :: String
- , perform :: PluginAction
- }
-
-instance Show Plugin where
- show (Plugin r p) = "matchRegex = " ++ r
+import Plugin.Base
matchPlugin :: String -> Maybe Plugin
matchPlugin message = firstPlugin $ matchPlugins message plugins
diff --git a/src/Plugin/Base.hs b/src/Plugin/Base.hs
new file mode 100644
index 0000000..c73ef6a
--- /dev/null
+++ b/src/Plugin/Base.hs
@@ -0,0 +1,17 @@
+module Plugin.Base
+ ( PluginAction
+
+ , Plugin(..)
+ , matchRegex
+ , perform
+ ) where
+
+type PluginAction = String -> String
+
+data Plugin = Plugin
+ { matchRegex :: String
+ , perform :: PluginAction
+ }
+
+instance Show Plugin where
+ show (Plugin r p) = "matchRegex = " ++ r