From 1f9c9d43ef475167ac6e886a71a782cf41bd549e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 14 Sep 2017 22:45:35 +0200 Subject: 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! --- src/Plugin/Help.hs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src') 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] -- cgit v1.2.3