From 25d384c07bfd47e661d21883cfb3a6fe21cfef37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 1 Jun 2024 15:25:41 +0200 Subject: Explicit run command in separate module Changelog: Explicit run command --- src/Command.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/Command.hs (limited to 'src/Command.hs') diff --git a/src/Command.hs b/src/Command.hs new file mode 100644 index 0000000..78d0d6c --- /dev/null +++ b/src/Command.hs @@ -0,0 +1,23 @@ +module Command ( + Command(..), + + CommandExec(..), + getConfig, +) where + +import Control.Monad.Reader + +import Config + +class Command c where + commandName :: proxy c -> String + + commandInit :: proxy c -> c + commandExec :: c -> CommandExec () + + +newtype CommandExec a = CommandExec (ReaderT Config IO a) + deriving (Functor, Applicative, Monad, MonadIO) + +getConfig :: CommandExec Config +getConfig = CommandExec ask -- cgit v1.2.3