From e94543c1b42bac8928aa8bf4fa3341563f7631b8 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 20 Aug 2017 12:42:28 +0200 Subject: Add Factorial plugin This plugin calculates factorials. It's not super optimised, but works for small inputs. Adds the 'text-show' plugin to convert the resulting integer to a `Data.Text` to be returned by the plugin action. At first I had tried /^\d+!$/ for the regex match, but that produced this error: sorbot/src/Plugin/Factorial.hs:14:24: error: lexical error in string/character literal at character 'd' Tried to fix that by using /^\\d+!$/, but that didn't match anything. Then tried a long-form character class, /^[:digit:]+!$/, which TDFA implies it supports, but a quick look at the code seems to indicate that those parts were removed or commented out. Not sure what was going on with that. So instead went for the remaining solution, a `0-9` character class. --- sorbot.cabal | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sorbot.cabal') diff --git a/sorbot.cabal b/sorbot.cabal index 7d23d3f..69bc228 100644 --- a/sorbot.cabal +++ b/sorbot.cabal @@ -23,6 +23,7 @@ library , Plugin , PluginList , Plugin.Base + , Plugin.Factorial , Plugin.GitHubCommit , Plugin.GitRemoteSetOrigin , Plugin.Help @@ -33,6 +34,7 @@ library , regex-tdfa , sqlite-simple , text + , text-show default-language: Haskell2010 executable sorbot-exe -- cgit v1.2.3