Adds GHCup.Prompt modules and its types to project
This commit is contained in:
parent
028696d4be
commit
c7eceb2330
@ -69,12 +69,14 @@ library
|
||||
GHCup.Prelude.Process
|
||||
GHCup.Prelude.String.QQ
|
||||
GHCup.Prelude.Version.QQ
|
||||
GHCup.Prompts
|
||||
GHCup.Requirements
|
||||
GHCup.Stack
|
||||
GHCup.Types
|
||||
GHCup.Types.JSON
|
||||
GHCup.Types.JSON.Utils
|
||||
GHCup.Types.Optics
|
||||
GHCup.Types.Prompts
|
||||
GHCup.Utils
|
||||
GHCup.Utils.Dirs
|
||||
GHCup.Version
|
||||
|
20
lib/GHCup/Prompts.hs
Normal file
20
lib/GHCup/Prompts.hs
Normal file
@ -0,0 +1,20 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module GHCup.Prompts
|
||||
(module GHCup.Types.Prompts,
|
||||
getUserPromptResponse)
|
||||
where
|
||||
|
||||
import GHCup.Types.Prompts
|
||||
import qualified Data.Text.IO as TIO
|
||||
import Control.Monad.IO.Class (MonadIO, liftIO)
|
||||
|
||||
putPrompt :: MonadIO m => PromptQuestion -> m ()
|
||||
putPrompt prompt = liftIO $ TIO.putStrLn prompt
|
||||
|
||||
getUserPromptResponse :: (MonadIO m) => PromptQuestion -> m PromptResponse
|
||||
getUserPromptResponse prompt = do
|
||||
putPrompt prompt
|
||||
resp <- liftIO TIO.getLine
|
||||
if resp `elem` ["YES", "yes", "y", "Y"]
|
||||
then pure PromptYes
|
||||
else pure PromptNo
|
8
lib/GHCup/Types/Prompts.hs
Normal file
8
lib/GHCup/Types/Prompts.hs
Normal file
@ -0,0 +1,8 @@
|
||||
module GHCup.Types.Prompts where
|
||||
|
||||
import Data.Text (Text)
|
||||
|
||||
type PromptQuestion = Text
|
||||
|
||||
data PromptResponse = PromptYes | PromptNo
|
||||
deriving (Show, Eq)
|
Loading…
Reference in New Issue
Block a user