aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2017-09-14 22:45:35 +0200
committerTeddy Wing2017-09-14 22:45:35 +0200
commit1f9c9d43ef475167ac6e886a71a782cf41bd549e (patch)
tree14b52a97984536edc8ea5ce20f2ebb9ec131e810
parentea190de02cea99347ae125d86cc22bf8cd926c88 (diff)
downloadsorbot-1f9c9d43ef475167ac6e886a71a782cf41bd549e.tar.bz2
Help: Fix type error resulting from new plugin list type with `Bot`
The plugin list's type has changed from `[Plugin]` to `[Bot Plugin]`. In order for our code here to work, we need to unwrap the `Bot` part so we can get access to the `Plugin` again and do the same work. Fortunately, using `sequence`, we can turn our `[Bot Plugin]` into a `Bot [Plugin]`, which is then easily bound with `<-` and passed to our old code to be handled like before. Yay!
-rw-r--r--src/Plugin/Help.hs15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/Plugin/Help.hs b/src/Plugin/Help.hs
index b29d1b9..ebe3760 100644
--- a/src/Plugin/Help.hs
+++ b/src/Plugin/Help.hs
@@ -23,17 +23,14 @@ help = do
helpAction :: PluginAction
helpAction _ = do
+ plugins' <- sequence plugins
return $ Right $ T.intercalate "\n"
- -- [T.justifyRight longestCommandLen ' ' (command p)
- -- `T.append` " – "
- -- `T.append` description p
- -- | p <- plugins']
+ [T.justifyRight (longestCommandLen plugins') ' ' (command p)
+ `T.append` " – "
+ `T.append` description p
+ | p <- plugins']
where
- longestCommandLen = foldr (max) 0 (map (T.length . command) plugins)
-
- helpText plugin = T.justifyRight longestCommandLen ' ' (command plugin)
- `T.append` " – "
- `T.append` description plugin
+ longestCommandLen plugins = foldr (max) 0 (map (T.length . command) plugins)
plugins :: [Bot Plugin]
plugins = PL.plugins ++ [help]