aboutsummaryrefslogtreecommitdiffstats
path: root/src/Plugin/GitHubCommit.hs
diff options
context:
space:
mode:
authorTeddy Wing2017-08-17 00:35:24 +0200
committerTeddy Wing2017-08-17 00:35:24 +0200
commitf4028e21f8a138961927b8e794b349f209b00dc7 (patch)
treef1099c1cd6ebd511a0a6d52c99c0545238be1a21 /src/Plugin/GitHubCommit.hs
parente9278eb0a1c0126e6903f333ed4efa5dd00ff5cc (diff)
downloadsorbot-f4028e21f8a138961927b8e794b349f209b00dc7.tar.bz2
Change `Plugin` and `Message` from `String` to `Data.Text`
Use the `Data.Text` type instead of `String` in most of the places we use it in `Plugin` and `Message`. This allows us to more easily pass data between the IRC package. No more kludgy `pack`s and `unpack`s in our IRC message handler. The one thing we couldn't convert was our regex. From what I understand (https://stackoverflow.com/questions/14922579/haskell-regular-expressions-and-data-text#14922626), the regex library I'm using doesn't support `Data.Text`, so use `String`s for that instead.
Diffstat (limited to 'src/Plugin/GitHubCommit.hs')
-rw-r--r--src/Plugin/GitHubCommit.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Plugin/GitHubCommit.hs b/src/Plugin/GitHubCommit.hs
index 9773690..ee694b4 100644
--- a/src/Plugin/GitHubCommit.hs
+++ b/src/Plugin/GitHubCommit.hs
@@ -4,6 +4,8 @@ module Plugin.GitHubCommit
( gitHubCommit
) where
+import qualified Data.Text as T
+
import Database.SQLite.Simple
import Database.SQLite.Simple.FromRow
import Text.Regex.TDFA
@@ -33,11 +35,12 @@ gitHubCommitAction message = do
Left "I couldn't find a repo URL for this channel. \
\Try `git remote set origin REPO_URL`."
respond ((RepoUrlRow r):_) =
- Right $ r ++ "/commits/" ++ M.text message =~ matchRegex gitHubCommit
+ Right $ r `T.append` "/commits/" `T.append` T.pack (
+ (T.unpack $ M.text message) =~ matchRegex gitHubCommit)
type Id = Int
-type RepoUrl = String
+type RepoUrl = T.Text
-- | A type to match the database table for this plugin.
data RepoUrlRow = RepoUrlRow RepoUrl