I'm a Haskell beginner and I am doing a small file for a project that should take the input of interaction data for groups of two people and save it to a list to be output at the end. I have done my best to implement this but it seems like the program hits the "stop" case no matter what is input. Any help or advice would be appreciated.
import Data.List
import Text.Read
main :: IO ()
main = do
putStrLn "This program is a means to record interactions between individuals during the COVID-19 pandemic."
putStrLn "Please enter your interactions in this format: 'x interacted with y'"
inputs <- getUserInputs
putStr "input: "
putStrLn ("list sequence " ++ show (inputs))
parseInput :: String -> Maybe String
parseInput input = if input == "stop" then Nothing else (readMaybe input):: Maybe String
getUserInputs :: IO [String]
getUserInputs = do
input <- getLine
case parseInput input of
Nothing -> return []
Just aString -> do
moreinputs <- getUserInputs
return (aString : moreinputs)
"a"it will work, but nota. You probably want to drop the readMaybe and have simply... else Just input.