Handle is semi-closed error in Haskell?
问题 I am getting this error in GHCI : *** Exception: <stdin>: hGetLine: illegal operation (handle is semi-closed) After running this code : main = do interact $ unlines . fmap proccess . take x . lines readLn :: IO Int And I am pretty sure the cause is take x . Is there any better way to read only x lines of input using interact or is interact just a solo player? 回答1: What you're trying to do isn't possible with interact . Behind the scenes interact claims the entirety of stdin for itself with