scala와 함께 scalaz 6.0을 사용하고 있습니다. 입력 스트림에서 읽기 위해 iteratees를 사용하고 있습니다.표준 입출력에서 입력 반복
내가 가진 simple.txt라는 간단한 파일이 있습니다.
이
는
테스트입니다
내 iteratee는 라인
def printLines: IterV[String, IO[Unit]] = {
def step(currentIO: IO[Unit])(input: Input[String]): IterV[String, IO[Unit]] =
input match {
case El(x) => Cont(
step(
currentIO.flatMap(_ => putStrLn(x))
)
)
case IterV.Empty() => Cont(step(currentIO))
case EOF() => Done(currentIO, EOF[String])
}
Cont(step(io()))
}
나는 enumeratorM를 사용
를 인쇄하는 IO 모나드를 구축 할 것입니다getFileLines(new File(".../simple.txt"))(printLines).flatMap(_.run).unsafePerformIO
올바른 출력을 검색합니다.
나는 나는 단지 "이"다시 콘솔 얻을
getLines(printLines).flatMap(_.run).unsafePerformIO
를 사용하려고하면. getLines는 표준 입력 스트림을 사용합니다. 디버그 문을 iteratee에 추가했고 getLines가 첫 번째 줄 다음에 EOF()를 보내는 것으로 보이며 해결할 수 없었습니다.