aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2017-07-30 18:03:11 +0200
committerTeddy Wing2017-07-30 18:03:11 +0200
commitbee8faa9804d37e3912e3704dbf03fc1c02eeb84 (patch)
tree18ded2ee5f5985fb749c18bd3f68cacc7807eff2 /src
parent4bb65c50a2a85404af6d122acc53b6fb1739652b (diff)
downloadsorbot-bee8faa9804d37e3912e3704dbf03fc1c02eeb84.tar.bz2
performPlugin: Use the correct match string
I had been using the regex instead of the match result. Do another regex match to correctly output our SHA instead of the match regex. I had tried putting the `=~` match in another function and using it from here and in the list comprehension in `matchPlugins`, but then found out that, of course, the return types didn't agree (`matchPlugins` needs a `Bool` and `performPlugin` needs a `String`). Ended up dispensing with the extra function and doing the match both times instead.
Diffstat (limited to 'src')
-rw-r--r--src/Lib.hs5
-rw-r--r--src/Plugin.hs4
2 files changed, 5 insertions, 4 deletions
diff --git a/src/Lib.hs b/src/Lib.hs
index a27ff99..abb8fe7 100644
--- a/src/Lib.hs
+++ b/src/Lib.hs
@@ -8,5 +8,6 @@ import Plugin
someFunc :: IO ()
someFunc = do
- let Just plugin = realMatchPlugin "75ac7b18a009ffe7a77a17a61d95c01395f36b44"
- putStrLn $ performPlugin plugin
+ let message = "75ac7b18a009ffe7a77a17a61d95c01395f36b44"
+ Just plugin = realMatchPlugin message
+ putStrLn $ performPlugin plugin message
diff --git a/src/Plugin.hs b/src/Plugin.hs
index 95f2461..e25a1dc 100644
--- a/src/Plugin.hs
+++ b/src/Plugin.hs
@@ -29,8 +29,8 @@ firstPlugin [] = Nothing
firstPlugin (p:ps) = Just p
-- TODO: Make a type for the `perform` function
-performPlugin :: Plugin -> String
-performPlugin p = perform p $ matchRegex p
+performPlugin :: Plugin -> String -> String
+performPlugin p message = perform p $ message =~ matchRegex p
gitHubCommit = Plugin
{ matchRegex = "^[0-9a-f]{40}$"