From 2d1098c1cd7842d464e4d8d7038fa050671e0c18 Mon Sep 17 00:00:00 2001 From: Mats Rauhala Date: Sun, 23 Dec 2018 23:52:19 +0200 Subject: [PATCH] Cleanup --- Setup.hs | 2 +- demobot.cabal | 4 ++++ release.nix | 1 + src/AppM.hs | 3 +-- src/Bot/Extension.hs | 8 ++++---- src/Bot/Lib.hs | 8 +++----- src/Extension/Hello.hs | 12 ++++++------ src/Extensions.hs | 1 - 8 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Setup.hs b/Setup.hs index 9a994af..4467109 100644 --- a/Setup.hs +++ b/Setup.hs @@ -1,2 +1,2 @@ -import Distribution.Simple +import Distribution.Simple main = defaultMain diff --git a/demobot.cabal b/demobot.cabal index 9ed9be2..4ebf588 100644 --- a/demobot.cabal +++ b/demobot.cabal @@ -34,10 +34,13 @@ library , exceptions hs-source-dirs: src default-language: Haskell2010 + ghc-options: -Wall executable demobot main-is: Main.hs other-modules: Extensions + , Extension.Hello + , AppM -- other-extensions: build-depends: base >=4.11 && <4.12 , demobot @@ -49,3 +52,4 @@ executable demobot , exceptions hs-source-dirs: src default-language: Haskell2010 + ghc-options: -Wall diff --git a/release.nix b/release.nix index 1fe28e2..9a60e05 100644 --- a/release.nix +++ b/release.nix @@ -9,6 +9,7 @@ let ghcid cabal-install hasktags + hlint (ghcWithPackages (_: demobot.buildInputs ++ demobot.propagatedBuildInputs)) nixpkgs.binutils-unwrapped ]; diff --git a/src/AppM.hs b/src/AppM.hs index 51674ca..a2c633b 100644 --- a/src/AppM.hs +++ b/src/AppM.hs @@ -8,7 +8,6 @@ import Bot.DSL import Control.Monad.Catch (MonadCatch, MonadThrow) import Control.Monad.Logger import Control.Monad.Trans (MonadIO, liftIO) -import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.IO as T import qualified Data.Time as Time @@ -23,7 +22,7 @@ instance MonadNetwork AppM where putMsg Response{..} = liftIO . T.putStrLn $ content instance MonadData AppM where - putData key val = liftIO $ T.putStrLn $ "Would put " <> T.pack key <> " = " <> (T.pack $ show val) + putData key val = liftIO $ T.putStrLn $ "Would put " <> T.pack key <> " = " <> T.pack (show val) getData key = liftIO (T.putStrLn $ "Would fetch " <> T.pack key) >> return Nothing instance MonadTime AppM where diff --git a/src/Bot/Extension.hs b/src/Bot/Extension.hs index e3068f0..e995b5e 100644 --- a/src/Bot/Extension.hs +++ b/src/Bot/Extension.hs @@ -1,9 +1,9 @@ -{-# Language Safe #-} -{-# Language RankNTypes #-} -{-# Language GADTs #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE Safe #-} module Bot.Extension where -import Bot.DSL +import Bot.DSL data Extension meta = Extension { act :: forall m. (meta ~ Meta m, MonadExtension m) => Request meta -> m (Maybe (Response meta)) , name :: String } diff --git a/src/Bot/Lib.hs b/src/Bot/Lib.hs index e32b4f0..3aca8d9 100644 --- a/src/Bot/Lib.hs +++ b/src/Bot/Lib.hs @@ -1,7 +1,6 @@ -{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE Safe #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeFamilies #-} module Bot.Lib where @@ -9,10 +8,9 @@ import Bot.DSL import Bot.Extension import Bot.Log import Control.Monad (forever) -import Control.Monad.Catch (MonadCatch, SomeException, catch, try) +import Control.Monad.Catch (MonadCatch, SomeException, catch) import Data.Maybe (catMaybes) import qualified Data.Text as T -import GHC.Stack tshow :: Show a => a -> T.Text tshow = T.pack . show @@ -25,5 +23,5 @@ mainLoop extensions = forever $ catch go handleFail go :: m () go = do msg <- recvMsg - responses <- catMaybes <$> mapM (\ext -> (act ext) msg) extensions + responses <- catMaybes <$> mapM (`act` msg) extensions mapM_ putMsg responses diff --git a/src/Extension/Hello.hs b/src/Extension/Hello.hs index 5a35c98..1749550 100644 --- a/src/Extension/Hello.hs +++ b/src/Extension/Hello.hs @@ -1,11 +1,11 @@ -{-# Language RecordWildCards #-} -{-# Language OverloadedStrings #-} -{-# Language ScopedTypeVariables #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ScopedTypeVariables #-} module Extension.Hello where -import Bot.Extension -import Bot.DSL -import qualified Data.Text as T +import Bot.DSL +import Bot.Extension +import qualified Data.Text as T extension :: Extension () extension = Extension{..} diff --git a/src/Extensions.hs b/src/Extensions.hs index 4b7161f..b491511 100644 --- a/src/Extensions.hs +++ b/src/Extensions.hs @@ -2,7 +2,6 @@ module Extensions where -import Bot.DSL import Bot.Extension import qualified Extension.Hello as Hello