I'm making a function readUntil that reads lines from user. Reading stops when f returns True for a line. Then the lines are returned as a list (the line that returned True is not included in that list). Here's what I have at the moment (some really raw/pseudo code now, excuse me):
readUntil :: (String -> Bool) -> IO [String]
readUntil f = fmap reverse (go []) where
go xs = do
x <- getLine
if f = True then return xs
else go (x : xs)
I would also like to make readUntil recursive (or implement a recursive helper function).
f = True. I'm a bit surprised to see such check.fapplied with parameterxisTrue, so I guess with a few hints you can come up with a solution.if f x == Trueand it works, thank you!a == Truehas the same value asa