From 3698d614bca4f88c2ffb0c4bf7867e8c5b140b8a Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 11 Sep 2017 00:48:23 +0200 Subject: Bot: Try adding a BotConfig type Tried adding this to replicate some code I had been reading, but ultimately it didn't really change anything. In the end I don't need this type, at least not right now, but it was an interesting exercise I suppose. --- src/Bot.hs | 8 ++++++-- src/Plugin/GitHubCommit.hs | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Bot.hs b/src/Bot.hs index a661ea4..fe1b0a1 100644 --- a/src/Bot.hs +++ b/src/Bot.hs @@ -1,15 +1,19 @@ --- {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE ConstraintKinds #-} -- {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} module Bot ( Bot(..) + , BotConfig ) where import Control.Monad.Reader import CliOptions (Options) +type BotConfig = MonadReader Options + newtype Bot a = Bot { runBot :: ReaderT Options IO a - } deriving (Monad, Functor, Applicative, MonadIO) + -- } deriving (Monad, Functor, Applicative, BotConfig, MonadIO) + } deriving (Monad, Functor, Applicative, MonadReader Options, MonadIO) diff --git a/src/Plugin/GitHubCommit.hs b/src/Plugin/GitHubCommit.hs index ad81e2f..fef4474 100644 --- a/src/Plugin/GitHubCommit.hs +++ b/src/Plugin/GitHubCommit.hs @@ -1,3 +1,4 @@ +-- {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} module Plugin.GitHubCommit @@ -14,12 +15,13 @@ import Database.SQLite.Simple.FromRow import Text.Regex.TDFA -- import Config (Config(..)) -import Bot (Bot, runBot) +import Bot (Bot, runBot, BotConfig) import I18n import qualified Message as M import qualified CliOptions as Cli (lang) import Plugin.Base +-- gitHubCommit :: BotConfig m => m Plugin gitHubCommit :: Bot Plugin gitHubCommit = do cfg <- ask -- cgit v1.2.3