prompt :: Text -> IO a -> (a -> Either Text b) -> IO b
prompt xs readerThing validate = do
- hSetBuffering stdout $ BlockBuffering $ Just 1;
+ hSetBuffering stdout $ BlockBuffering $ Just 1
hSetBuffering stdin NoBuffering
+
putStr xs
response <- readerThing
case validate response of
subPrompt :: IO a -> IO b -> (a -> Bool) -> IO (Maybe (a, b))
subPrompt p1 p2 showNext = do
- p1 >>= (\x -> if showNext x then p2 >>= (\y -> return $ Just (x,y)) else return Nothing)
+ p1 >>= (\x -> if showNext x then p2 >>= (return . Just . (x, )) else return Nothing)
textPrompt :: Text -> IO Text
textPrompt xs = prompt xs getLine Right