Pointfree life
authorCameron Ball <cameron@moodle.com>
Thu, 20 Jun 2019 07:06:50 +0000 (15:06 +0800)
committerCameron Ball <cameron@moodle.com>
Thu, 20 Jun 2019 07:06:50 +0000 (15:06 +0800)
src/Prompts.hs

index 240c1cf..72530d6 100644 (file)
@@ -25,8 +25,9 @@ cannotBeEmpty xs = case null xs of
 
 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
@@ -35,7 +36,7 @@ prompt xs readerThing validate = do
 
 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