aboutsummaryrefslogtreecommitdiffstats
path: root/src/Plugin
diff options
context:
space:
mode:
authorTeddy Wing2017-09-11 00:53:30 +0200
committerTeddy Wing2017-09-13 04:47:08 +0200
commitae6949327ed8bd8cfa528da7741333274203af44 (patch)
tree040fa1b05213378fe34531e634853608d0c613be /src/Plugin
parent515de5dd5d44fb361fe7ca68d698776e84c4d523 (diff)
downloadsorbot-ae6949327ed8bd8cfa528da7741333274203af44.tar.bz2
gitHubCommit: Fix type error
Oh my goodness, it works!!!!!!! I've been wrestling with this for the past week and a half, and it finally works! Here's the compiler error I was getting: sorbot/src/Plugin/GitHubCommit.hs:25:12: error: • Couldn't match type ‘Control.Monad.Trans.Reader.ReaderT r0 m1’ with ‘Bot’ Expected type: Bot t0 Actual type: Control.Monad.Trans.Reader.ReaderT r0 m1 t0 • In a stmt of a 'do' block: cfg <- asks language In the expression: do { cfg <- asks language; return (defaultPlugin {matchRegex = "^[0-9a-f]{40}$", perform = gitHubCommitAction, command = "<git_sha>", description = translate (lang cfg) GitHubCommitDescription}) } In an equation for ‘gitHubCommit’: gitHubCommit = do { cfg <- asks language; return (defaultPlugin {matchRegex = "^[0-9a-f]{40}$", perform = gitHubCommitAction, command = "<git_sha>", description = translate (lang cfg) GitHubCommitDescription}) } The problem ended up being that I was using the wrong `ask` & `asks` functions. After a lot of searching online and reading articles and things about how to set up `ReaderT` configuration, I finally started looking at some code, from a "language:Haskell newtype app readert" search on GitHub. Reading different code bits, I tried to compare with what I had already, kept reading. Finally I noticed that the imports were different, and I tried getting `ask` not from the transformer library, and it worked!! OMG! So glad.
Diffstat (limited to 'src/Plugin')
-rw-r--r--src/Plugin/GitHubCommit.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Plugin/GitHubCommit.hs b/src/Plugin/GitHubCommit.hs
index a1e5ce4..335c664 100644
--- a/src/Plugin/GitHubCommit.hs
+++ b/src/Plugin/GitHubCommit.hs
@@ -7,7 +7,8 @@ module Plugin.GitHubCommit
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Class (lift)
-import Control.Monad.Trans.Reader (ask, asks)
+-- import Control.Monad.Trans.Reader (ask, asks)
+import Control.Monad.Reader (ask, asks)
import qualified Data.Text as T
import Database.SQLite.Simple
@@ -47,7 +48,7 @@ gitHubCommitAction message = do
respond rs
where
- respond :: Bot (Either T.Text T.Text)
+ respond :: [RepoUrlRow] -> Bot (Either T.Text T.Text)
respond [] = do
cfg <- ask
-- lang <- Cli.lang