From b8dac2d7cd6d1aff8309df44a6399df9304734e3 Mon Sep 17 00:00:00 2001 From: Arjun Kathuria Date: Tue, 28 Jun 2022 19:45:17 +0530 Subject: [PATCH] Updates the Prompt module to use logInfo instead of putStrLn, makes the prompt look prettier --- lib/GHCup/Prompts.hs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/GHCup/Prompts.hs b/lib/GHCup/Prompts.hs index c1f537d..08bed33 100644 --- a/lib/GHCup/Prompts.hs +++ b/lib/GHCup/Prompts.hs @@ -1,17 +1,28 @@ {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE FlexibleContexts #-} + module GHCup.Prompts - (module GHCup.Types.Prompts, - getUserPromptResponse) + ( module GHCup.Types.Prompts, + getUserPromptResponse, + ) where -import GHCup.Types.Prompts +import Control.Monad.Reader import qualified Data.Text.IO as TIO -import Control.Monad.IO.Class (MonadIO, liftIO) +import GHCup.Prelude.Logger +import GHCup.Types.Optics +import GHCup.Types.Prompts -putPrompt :: MonadIO m => PromptQuestion -> m () -putPrompt prompt = liftIO $ TIO.putStrLn prompt +putPrompt :: (HasLog env, MonadReader env m, MonadIO m) + => PromptQuestion + -> m () +putPrompt prompt = logInfo prompt -getUserPromptResponse :: (MonadIO m) => PromptQuestion -> m PromptResponse +getUserPromptResponse :: ( HasLog env + , MonadReader env m + , MonadIO m) + => PromptQuestion + -> m PromptResponse getUserPromptResponse prompt = do putPrompt prompt resp <- liftIO TIO.getLine